geoman-io / leaflet-geoman

🍂🗺️ The most powerful leaflet plugin for drawing and editing geometry layers
https://geoman.io
MIT License
2.19k stars 431 forks source link

Programmatically remove layers - delete all shapes #515

Closed Rombecchi closed 4 years ago

Rombecchi commented 4 years ago

Hi, aside the "RemovalMode", is it possible to programmatically delete a single or multiple layer(s)? How can I delete all shapes from my map? Thank you so much!

codeofsumit commented 4 years ago

Hi, you can do this with leaflet alone:

map.eachLayer(function(layer){
    layer.removeLayer();
});

https://leafletjs.com/reference-1.6.0.html#map-eachlayer

torrid33 commented 1 year ago

Is it possible to delete shapes within a layer and then add more shapes to that layer rather than removing that layer?

Falke-Design commented 1 year ago

Not with Geoman. But maybe there is a Leaflet plugin that you can use https://leafletjs.com/plugins.html