1

我正在使用 Leaflet 开发一个 web 地图应用程序。该应用程序使用户能够使用 Leaflet Leaflet.Draw 插件在地图上绘制对象。用户还可以编辑或删除绘制的对象。

我在 Leaflet Draw 中的 revertLayers 函数有一些问题。当用户取消更改时,图层将恢复到其原始状态,但在下一次编辑中,它显示用于拖动对象节点的点未恢复。

在此处输入图像描述

这是我的编辑控件代码:

var editCtrlOptions = {
    featureGroup: editableLayers,
    selectedPathOptions: {
        maintainColor: true,
        opacity: 0.3
    }
}

var editCtrl = new L.EditToolbar.Edit(map, editCtrlOptions);

// On edit button click 
$('body').on("click", "#btn-edit", function() {
    // enable the edit control
    editCtrl.enable(); 
});

// On save edit button click
$('body').on("click", "#btn-edit-save", function() {
    // commit any changes made by the user
    editCtrl.save();
    // disable the edit control
    editCtrl.disable(); 
});

// On cancel edit button click
$('body').on("click", "#btn-edit-cancel", function() {
    // revert any changes made by the user
    editCtrl.revertLayers();    
    // disable the edit control
    editCtrl.disable(); 
});
4

1 回答 1

0

我认为这可能与 Leaflet.Draw 插件的 0.3.0 版本有关。我更改为 0.2.7 版本,问题就消失了。

于 2016-07-27T23:54:27.137 回答