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.
Asked
Active
Viewed 1.3k times
16

Carpetfizz
- 8,707
- 22
- 85
- 146
1 Answers
33
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.

l85m
- 808
- 1
- 10
- 19
-
4I 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? – Jake T. Oct 02 '18 at 18:41
-
how to call removeLayer – Samiksha Jagtap Sep 12 '22 at 10:59