You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
Every time I run this function it adds GeoJSON to the map. I take the GeoJSON data of the existing MGLShapeSource using geoJSONData() and manually merge with the new GeoJSON and replace the entire source with the merged. When I adding the second set of data I noticed that it replaced the Features instead of appending. Debugging, I noticed that MGLShapeSource.shape is always nil so there is no old data for a merge. I have attached an Example project where you can Add Source 1 and Add Source 2 but they will always replace the previous data.
This is a limitation of GeoJSON sources in core GL. You can keep your own reference to the MGLShapeSource object, which keeps track of the shape with which it was initialized. Otherwise, if you rely on MGLStyle.source(withIdentifier:) to obtain an MGLShapeSource object, that’s actually a different object that has no access to the original shape data (which has since been cut into tiles): #7376.
For others with this issue: I added a class variable to store the reference. On each mapDidFinishLoading() (first load, plus and map style changes) I'm re-init'ing the MGLShapeSource and assigning it to that variable so the rest of the class has a reference.
iOS
Mapbox 3.6.1 (test 3.5.0 as well)
Every time I run this function it adds GeoJSON to the map. I take the GeoJSON data of the existing
MGLShapeSource
usinggeoJSONData()
and manually merge with the new GeoJSON and replace the entire source with the merged. When I adding the second set of data I noticed that it replaced the Features instead of appending. Debugging, I noticed thatMGLShapeSource.shape
is always nil so there is no old data for a merge. I have attached an Example project where you can Add Source 1 and Add Source 2 but they will always replace the previous data.oldShape
is always nil.Download example project
The text was updated successfully, but these errors were encountered: