dimfeld / svelte-maplibre

Svelte bindings for the MapLibre mapping library
https://svelte-maplibre.vercel.app
MIT License
283 stars 34 forks source link

After baselayer switch GeoJSON source data cannot be updated #74

Closed mhrgoldberg closed 9 months ago

mhrgoldberg commented 9 months ago

I have had a need for a while to switch baselayers, so much thanks to those who contributed to the recent updates enabling this.

I have found a bug which I have recreated in the demo site. When the baselayer is switched and the sources are re-added to the map the source component does not reset the local reference to the sourceObj so when data in the source layer is updated it does not show up on the map. You can see this behavior in the below video:

https://github.com/dimfeld/svelte-maplibre/assets/34895686/2b494002-07fb-4a13-b6ef-1ecdbc09ff8d

We can fix this by having the GeoJSON component listen to the style.load event and update the sourceObj whenever it loads. I will create a PR momentarily to address this.