Leaflet.Snap 无法将折线捕捉到 guideLayer

Leaflet.Snap can't snap a polyline to guideLayer

我尝试在绘制新多段线时捕捉 guideLayer 上的多段线点。当我接近 guideLayer 时,我的鼠标会捕捉到它,但我无法在 guideLayer 上添加新点。

我的地图和控件声明如下:

var mymap = L.map('map').setView([46.658, 7.011], 14);
var drawnItems = new L.FeatureGroup();         
var mymap.addLayer(this.drawnItems);
var tracksGeoJson = L.geoJSON(listTracks).addTo(mymap);
var guideLayers = [tracksGeoJson];

var drawControl = new L.Control.Draw();
var drawControl.initialize({
    edit: {
        featureGroup: drawnItems 
        },
    draw: {
        polygon: false,
        circle: false,
        rectangle: false,
        marker: false,
        polyline: {guideLayers: display.guideLayers, snapDistance: 10}
    }
});
mymap.addControl(this.drawControl);      

我正在使用 Leaflet v1.0.3、Leaflet.draw v0.49 和 Leaflet.Snap v0.0.4。

找到了!

"snapDistance" 选项不适用于多段线。所以新的 drawControl 初始化是:

var drawControl = new L.Control.Draw();
var drawControl.initialize({
    edit: {
        featureGroup: drawnItems 
        },
    draw: {
        polygon: false,
        circle: false,
        rectangle: false,
        marker: false,
        polyline: {guideLayers: display.guideLayers}
    }
});
mymap.addControl(this.drawControl);

现在我可以在其他折线上添加折线点了。