Friday, 15 November 2019

Switch GeoJsonSource data in MapBox

I want to replace the data behind an existing source. This is trivial in javascript:

map.getSource('trace').setData(data);

See https://docs.mapbox.com/mapbox-gl-js/example/live-update-feature/

That method does not exist in Android. Once I have set a value, I can't replace it (nothing changes if I do):

GeoJsonSource mySource;
mySource.setGeoJson("some json data");

To delete and readd the source, I'd have to remove the layer using the source first: https://github.com/mapbox/mapbox-gl-native/issues/12526

Since I'm getting a fully functioning Style object from the server, removing, recreating and readding the layer/source at the correct position is tedious to say the least.



from Switch GeoJsonSource data in MapBox

No comments:

Post a Comment