Removing a source in mapbox gl js doesn't remove its layers
Asked Answered
G

1

17

I'm trying to selectively remove a source in mapbox gl js, I'm using map.removeSource('<SOURCE_ID>') but nothing happens. The layers still remain on the map. I've created an example in Codepen.

Guy answered 27/2, 2017 at 5:24 Comment(0)
M
35

You've got to remove the source and the layer. Call removeLayer first (since it depends on the source) and then remove the source next.

Massif answered 27/2, 2017 at 5:52 Comment(3)
I believe I have removed the layer already, but the source seems to be in use still. Is there any way to see what layer is using a source by chance?Copier
how to call removeLayerInterurban
Is there any progress? I'm still confronted with the same problem. Even after removing the Layer it says Source '<source layer name>' is in use, cannot removeIlluminant

© 2022 - 2024 — McMap. All rights reserved.