我在绘制新的折线时尝试在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。
答案 0 :(得分:0)
我找到了它!
“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);
现在我可以在其他折线上添加折线点。