As seen in the image below, I’d like to remove the option to cancel a drawing. Here’s my code:
With that code you can remove the "cancel" button on all shapes:
L.DrawToolbar.prototype.getActions = function (handler) {
return [
{
enabled: handler.completeShape,
title: L.drawLocal.draw.toolbar.finish.title,
text: L.drawLocal.draw.toolbar.finish.text,
callback: handler.completeShape,
context: handler
},
{
enabled: handler.deleteLastVertex,
title: L.drawLocal.draw.toolbar.undo.title,
text: L.drawLocal.draw.toolbar.undo.text,
callback: handler.deleteLastVertex,
context: handler
}
];
}
Original code: Doc
Also you can allow the cancel button for handlers when you add a if and test if the correct handler is passed.
PS: For a newer "leaflet-draw" you can use Leaflet-Geoman