Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 944
Carpetfizz Avatar asked Feb 27 '17 05:02

Carpetfizz


1 Answers

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.

like image 118
l85m Avatar answered Oct 03 '22 23:10

l85m