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.
You can simply use the removeLayer method, like this:
map.removeLayer(layerGroup)
Take a look at this plunker (click on the map to remove the layer):
http://plnkr.co/edit/jSUE8ft9p7odLhQGeOVa
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With