16

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.

Carpetfizz
  • 8,707
  • 22
  • 85
  • 146

1 Answers1

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