如何从传单绘制api删除按钮中删除保存选项



我的问题类似于传单绘制删除按钮删除"清除所有";操作,但我想删除保存选项,而不是全部清除。

您可以通过L.EditToolbar.include函数检索EditToolbar的操作,并在不包括保存选项的情况下返回操作:

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;
}
});

好吧,drawin-api没有提供自定义功能。所以我添加了一个自定义css来隐藏它。

除此之外,我们还可以自定义插件如下:要更改文本:L.drawLocal.edit.toolbar.actions.clearAll.text = t('Clear');

覆盖清除方法:

L.EditToolbar.Delete.prototype._enableLayerDelete = function(t) {
me.drawToolbar = this;
(t.layer || t.target || t).on("click", me.clearAllCustom, this)
};

额外的CSS对我来说是一个很好的解决方案。我添加了代码,因为它在前面的回答中没有提供:

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;
}

最新更新