it is easy to add a layerGroup to a leaflet map by simply calling layergroup.addTo(map)
.
How I can I remove the whole layergroup
from the map? I tried layergroup.eachLayer(function(layer) { map.removeLayer(layer);});
But, the map begins to behaviour weirdly.
How to remove a layerGroup in leaflet?
18.8k views Asked by Jerry Yuan At
2
You can simply use the removeLayer method, like this:
Take a look at this plunker (click on the map to remove the layer):
http://plnkr.co/edit/jSUE8ft9p7odLhQGeOVa