geoman-io / leaflet-geoman

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

Remove Control #520

Closed meteerogl closed 4 years ago

meteerogl commented 4 years ago

Now, we are using leaflet.draw and there are lots of layers in used map. I am adding initial layers when opening map as L.FeatureGroup. I tested Geoman in our project. But when I using Geoman and click any layers, after remove mode(in geoman); I can remove all layers. For example

drawnItems = new L.FeatureGroup(); drawnItems.addLayer(layers.shelves); layers.walls.addTo(map);

I want to this; User can remove or edit shelves but can not edit or remove wall. How can I do. Can I enable drawing mode for some specific layers.

DazDotOne commented 4 years ago

If you never need to edit certain layers, this is quite trivial to achieve:

L.marker([51.50915, -0.096112], { pmIgnore: true }).addTo(map);

you can also make Geoman an opt-in system.

All layers will be ignored by leaflet-geoman, unless you specify pmIgnore: false on a layer:

From the docs

L.PM.initialize({ optIn: true });

L.marker([51.50915, -0.096112], { pmIgnore: false }).addTo(map);

You may need to experiment a little with your layers.walls variable though.

codeofsumit commented 4 years ago

@DazDotOne thanks for helping out around here! Really appreciate it