Open mblomdahl opened 6 years ago
@mblomdahl I would recommend:
styledata
event.
if (map.getLayer('my-layer')) { map.removeLayer('my-layer') }
if ((map.getSource('my-source')) { map.removeSource('my-layer') }
cc @juliemunro
add me to the review team :)
When attempting to update GL JS version from 0.40.1 to 0.44.1, we found that the style-layer switching no longer works.
How it was (successfully) handled in the latest mapbox-gl-circle version:
styledataloading
upon being added to a mapstyledata
firingstyledata
firing, the circle would add itself back to the mapWas working really well.
Here's the code that does it:
What happens with the latest version is that remove() call fails because, apparently, the circle assets already does not exist.
Question: @ryanbaumann is there some earlier event we should listen to in order to detect-and-handle a style layer change?