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.
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:
initialize a map with a style that have a few sources and layers linked to them
call map.setStyle('new-style-url', {diff: true)
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.
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.
In maplibre 4 when using
setStyle
withdiff: true
, maplibre knows how to replace the map correctly without the former bailout. Due to this "new" behavior if yousetStyle
with more than one source diff it may fail sincerender
is called in the middle of the switch after the first source has changed.Steps to reporduce:
map.setStyle('new-style-url', {diff: true)
Source "Contour" cannot be removed while layer "Contour_contour_circle" is using it.
This is caused due to the
setStyle
insiderender
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.