Disable leaflet-draw “delete” button

2019-02-28 03:28发布

问题:

How can I disable/remove the delete button in the leaflet-draw edit toolbar? The "edit" button should remain enabled.

回答1:

Regarding to the docs in chapter Disabeling a Toolbar Item you can do the following:

    map.addControl(new L.Control.Draw({
        edit: { 
                featureGroup: drawnItems,
                remove: false 
              }
    }));

This adds a new Control bar without the delete Button, but the edit button will remain