使用javascript,我該如何更改leaflet.draw「垃圾桶」按鈕刪除所有已繪製並自動保存的多邊形。下面是我已經實現的代碼,但它是一個完整的黑客。它消除了積極的多邊形,但之後,我刪除的對象,一旦我開始得到錯誤控制檯,當我點擊喜歡NotFoundError: Node was not found
和TypeError: this._deletedLayers is null
leaflet.draw垃圾按鈕刪除所有多邊形並保存
map.on('draw:editstart', function (e) {
if(e.handler == 'remove' && typeof drawnItem != 'undefined' && drawnItem !== null){
if(window.console) window.console.log('Drawing deleted...');
if(typeof drawnItem != 'undefined' && drawnItem !== null){
drawnItems.removeLayer(drawnItem);
}
$('.leaflet-draw.leaflet-control .leaflet-draw-actions').hide();
$('.leaflet-popup-pane .leaflet-draw-tooltip').remove();
}
});
看起來好像這可能無法與leaflet.draw但除非一個讓自定義生成: https://github.com/Leaflet/Leaflet.draw/issues/264 – jduhls