Leaflet / Leaflet.draw

Vector drawing and editing plugin for Leaflet
https://leaflet.github.io/Leaflet.draw/docs/leaflet-draw-latest.html
MIT License
1.97k stars 992 forks source link

Disable button on toolbar #762

Open vmagalhaes opened 7 years ago

vmagalhaes commented 7 years ago

Hi,

I need remove this buttons when I click at polyline or polygon.

Have a way to remove this?

image

Thanks

ddproxy commented 7 years ago

Have you tried modifying L.drawLocal actions to remove the values from the edit: toolbar: ? https://github.com/Leaflet/Leaflet.draw/blob/a539be549ccca50ea7039d698f783d13f7a0a7b5/src/Leaflet.draw.js#L154

vmagalhaes commented 7 years ago

@ddproxy yeh, but it breaks when I click on edit button

vmagalhaes commented 7 years ago

image

Tallon159 commented 6 years ago

Did you find a way to remove the actions ? I need this too.

vmagalhaes commented 6 years ago

Did you find a way to remove the actions ? I need this too.

Unfortunately no, I tried, but I doesn't work.

JohnCos247 commented 5 years ago

@vmagalhaes @dmizrahi here is what I did to remove the buttons it unfortunately is not perfect since there is no way to remove the parent "li" element. I dug through the source code for a bit to find the logic for button creation and looks like there is no option to disable. Hope this semi functioning solution helps hold you over until a proper fix is put in place.

I first edited the title of the ones I wanted to hide with a custom title "my-custom-leaflet-hide". L.drawLocal.draw.toolbar.finish.title = 'my-custom-leaflet-hide'; L.drawLocal.draw.toolbar.actions.text = 'New Cancel Name // I want to keep this one. L.drawLocal.draw.toolbar.undo.title = 'my-custom-leaflet-hide'; // Add the controls to my map new L.Control.Draw(options).addTo(myMap);

Once I did this I added this line to my CSS as the buttons are anchor tags. I referenced the title attribute to hide the elements.

a[title="my-custom-leaflet-hide"] { display: none !important; }

Screen Shot 2019-04-02 at 4 12 48 PM