2017-10-05 53 views
0

我在繪製新多段線時嘗試在指導層上捕捉多段線點。當我接近它時,我的鼠標對齊指南層,但我無法在guideLayer上添加一個新點。Leaflet.Snap無法將多段線對齊到指導層

我的地圖顯示和控制的聲明如下:

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);  

我使用單張V1.0.3,Leaflet.draw v0.49和Leaflet.Snap v0.0.4。

回答

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); 

現在我可以在其他多段線上添加多段線點。