在leaflet.draw收费栏中启用“捕捉捕捉”选项

时间:2019-06-13 06:51:12

标签: javascript leaflet leaflet.draw

我想在Leaflet绘制工具栏中启用“捕捉对齐”选项,以便用户编辑现有特征时可以捕捉到相邻特征

在编辑时,图层可以自动对齐。所以我从引导层删除了编辑层。 editLyr 包含单个多边形, editGuideLyr 包含其余的多边形,但是editLyr不能与editGuideLyr对齐

当前层包含所有多边形层

drawGuideLyr = currLyr.getLayers();
editLyr.addLayer(currLyr.getLayers()[0]);
tempLyr.removeLayer(editLyr.getLayers()[0]);
editGuideLyr = tempLyr.getLayers();

绘图工具栏选项

    var drawPluginOptions = {
    position: 'topleft',
    draw: {
        polygon: {            
            guideLayers: drawGuideLyr,
            snapDistance: 10,
            allowIntersection: false,
            showArea: true,
            drawError: {
               color: '#b00b00',
               timeout: 1000
            }},
            polyline: false,
            circle: false,
            rectangle: false,
            marker: false,
        },
    // Try 1
    edit: {
        featureGroup: editLyr,
        edit:{            
            snapOptions: {
                guideLayers: editGuideLyr,
            },
        },
        remove: false,
    },
   //Try2
     edit: {
        featureGroup: editLyr,
        edit:true,            
        snapOptions: {
          guideLayers: editGuideLyr,  
        },
        remove: false,
    },
};

在绘制新多边形时,捕捉工作正常,但是在编辑现有多边形时,捕捉工作不起作用

0 个答案:

没有答案