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 was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Adding/removing a GeoJSON source doesn't show in layer till map is zoomed in/out #6612
This sounds different than #6177. As of beta 3, we’re correctly invalidating the map when a layout or paint property or filter is set; however, swapping out a source is probably distinct from changing a filter.
@jfirebaugh, does this sound like something that should’ve been fixed by #6201, or is it another special case?
@cammace Just to clarify, this issue is not about updating a GeoJsonSource (like the title suggests), but replacing it all together with add/removeSource right?
This is exposing some lax behavior in our runtime styling APIs -- it's not actually intended to be possible to remove a source that's currently in use by one or more layers, add another source with the same ID but different data, and have the layers update to the new data. (Doing so potentially violates numerous invariants that the style attempts to enforce.)
Instead, removing an in-use source should either:
Produce an error indicating that the layers that use it need to be removed first, or
changed the title [-]Updated GeoJSON source changes don't show in layer till map is zoomed in/out[/-][+]Adding/removing a GeoJSON source doesn't show in layer till map is zoomed in/out[/+]on Oct 11, 2016
It should be noted that the same behavior is seen if one changes the backing data in a geojson source
(e.g. layers not not invalidating until the map is invalidated by zoom or some other event)
String serializedGeoJsonData = getNewGeoJsonData();
final GeoJsonSource source = mapboxMap.getSourceAs("geoJsonData");
source.setGeoJson(serializedGeoJsonData);
@damianflannery Could you share some code (minimal case) so we can see how you're doing this? The original issue was about removing/adding a source to get layers updated, you seem to be doing something else.
@damianflannery Thanks for the example code. That cleared things up a lot.
There is a slight issue in your code that triggers this behaviour. You add sources, but never remove them. The issues start appearing when a source is added twice for the same id it seems. If your remove your source, just as the layers. It works as expected. See this patch for details.
If you want to get the most out of it in your real application btw, it might be worth toggling the opacity or visibility on layers instead of remove/adding them. This often gives a smoother transition.
Activity
rmnblm commentedon Oct 7, 2016
Might be the same issue as I had with iOS, see #6177 (comment)
1ec5 commentedon Oct 7, 2016
This sounds different than #6177. As of beta 3, we’re correctly invalidating the map when a layout or paint property or filter is set; however, swapping out a source is probably distinct from changing a filter.
@jfirebaugh, does this sound like something that should’ve been fixed by #6201, or is it another special case?
ivovandongen commentedon Oct 7, 2016
@cammace Just to clarify, this issue is not about updating a
GeoJsonSource(like the title suggests), but replacing it all together with add/removeSource right?jfirebaugh commentedon Oct 7, 2016
This is exposing some lax behavior in our runtime styling APIs -- it's not actually intended to be possible to remove a source that's currently in use by one or more layers, add another source with the same ID but different data, and have the layers update to the new data. (Doing so potentially violates numerous invariants that the style attempts to enforce.)
Instead, removing an in-use source should either:
[-]Updated GeoJSON source changes don't show in layer till map is zoomed in/out[/-][+]Adding/removing a GeoJSON source doesn't show in layer till map is zoomed in/out[/+]ivovandongen commentedon Oct 11, 2016
@jfirebaugh Agreed. I would prefer an error in this situation to make it abundantly clear that this is an unsupported operation.
I removed this from the upcoming release milestone as it is not a blocker.
sddamico commentedon Oct 18, 2016
It should be noted that the same behavior is seen if one changes the backing data in a geojson source
(e.g. layers not not invalidating until the map is invalidated by zoom or some other event)
sddamico commentedon Oct 18, 2016
My current workaround is
mapboxMap.moveCamera(CameraUpdateFactory.zoomBy(0.0001f));jfirebaugh commentedon Oct 18, 2016
@sddamico That's #5906, and should be fixed in v4.2.0-beta.3.
sddamico commentedon Oct 18, 2016
@jfirebaugh I'm using
v4.2.0-beta.3and the issue as I described is present.jfirebaugh commentedon Oct 19, 2016
Ok, please open a fresh issue.
sddamico commentedon Oct 19, 2016
@jfirebaugh done: #6744
damianflannery commentedon Nov 9, 2016
I am also facing this issue with beta4. I call removeLayer(layerId) before adding a new layer (with different id).
I recorded a short recording here (glitch happens at 11 seconds from start)
https://dl.dropboxusercontent.com/u/27007357/mapbox_geojsonsource_glitch.mp4
ivovandongen commentedon Nov 9, 2016
@damianflannery Could you share some code (minimal case) so we can see how you're doing this? The original issue was about removing/adding a source to get layers updated, you seem to be doing something else.
damianflannery commentedon Nov 10, 2016
@ivovandongen Sure, I created a sample project here:
https://github.com/damianflannery/MapboxGlitch
I also created another recording of the issue using this sample and log output below (Nexus 5X, Adnroid 6.0.1):
https://dl.dropboxusercontent.com/u/27007357/navenio/glitch.mp4
Thanks for taking a look.
ivovandongen commentedon Nov 10, 2016
@damianflannery Thanks for the example code. That cleared things up a lot.
There is a slight issue in your code that triggers this behaviour. You add sources, but never remove them. The issues start appearing when a source is added twice for the same id it seems. If your remove your source, just as the layers. It works as expected. See this patch for details.
If you want to get the most out of it in your real application btw, it might be worth toggling the opacity or visibility on layers instead of remove/adding them. This often gives a smoother transition.
damianflannery commentedon Nov 10, 2016
Ah, now works perfectly. Thank you @ivovandongen :)