maplibre / maplibre-gl-inspect

Maplibre GL Inspect adds an inspect control to maplibre-gl-js to view all features of the vector sources and allows hovering over features to see their properties.
https://maplibre.org/maplibre-gl-inspect/
BSD 3-Clause "New" or "Revised" License
40 stars 7 forks source link

Changing a style causes failure #13

Closed HarelM closed 8 months ago

HarelM commented 8 months ago

In maplibre 4 when using setStyle with diff: true, maplibre knows how to replace the map correctly without the former bailout. Due to this "new" behavior if you setStyle with more than one source diff it may fail since render is called in the middle of the switch after the first source has changed.

Steps to reporduce:

  1. initialize a map with a style that have a few sources and layers linked to them
  2. call map.setStyle('new-style-url', {diff: true)
  3. See the following error in the condole (for example): Source "Contour" cannot be removed while layer "Contour_contour_circle" is using it.

This is caused due to the setStyle inside render called due to the source changed event.

This is also described here:

Solution: Throttle the source changed calls with trail so that if there are multiple sources changes it will do them after the style has completed the transition.