My question is similar to leaflet-draw delete button remove "clear all" action but I want to remove save option instead of clear all.
Asked
Active
Viewed 1,183 times
3 Answers
0
Well, there are no customization provided by draw api to do that. So I have added a custom css to hide it.
Apart from that, we can also customized the plugin as follows :
To change the text :
L.drawLocal.edit.toolbar.actions.clearAll.text = t('Clear');
To overwrite the clear method :
L.EditToolbar.Delete.prototype._enableLayerDelete = function(t) {
me.drawToolbar = this;
(t.layer || t.target || t).on("click", me.clearAllCustom, this)
};

Abhijit Misra
- 136
- 1
- 8
0
The additional CSS was a good solution for me. I add the code, as it was not provided in the previous answer:
ul.leaflet-draw-actions.leaflet-draw-actions-bottom li a[title="Save changes"],
ul.leaflet-draw-actions.leaflet-draw-actions-bottom li a[title="Cancel editing, discards all changes"] {
display: none;
}

scpsc
- 1
- 1
0
You can retrieve the actions of the EditToolbar via L.EditToolbar.include function and return the actions while not including the save option:
L.EditToolbar.include({
getActions: function (handler) {
var actions = [
{
title: L.drawLocal.edit.toolbar.actions.cancel.title,
text: L.drawLocal.edit.toolbar.actions.cancel.text,
callback: this.disable,
context: this
}
];
if (handler.removeAllLayers) {
actions.push({
title: L.drawLocal.edit.toolbar.actions.clearAll.title,
text: L.drawLocal.edit.toolbar.actions.clearAll.text,
callback: this._clearAllLayers,
context: this
});
}
return actions;
}
});