我試圖將Leaflet Editable functionality添加到我當前的地圖,該地圖是由傳單指令創建的。我剛剛接到L.map實例:重複使用Leaflet指令的現有地圖實例
leafletData.getMap().then(function(map) {
// where map is the Leaflet map instance
}
然而,單張編輯需要設置editable: true
創建地圖時。
那麼,有沒有一種方法來創建一個實例L.map
var map = L.map('map', {editable: true});
,然後將其連接到單張角指令?
UPDATE:
我嘗試添加一個鉤子單張
L.Map.addInitHook(function() {
this.whenReady(function() {
this.editTools = new L.Editable(this, this.options.editOptions);
console.log('L.map', this);
});
}
它成功地創建了editTools但
map.editTools.startPolyline();
仍然沒有工作
嘗試,失敗:( –
您可以驗證,如果它真的通過檢查設置您的地圖實例的選項對象:'console.log(map.options.editable);' – iH8
將editable屬性添加到默認值根本不起作用。我已經用我的la更新了這個問題第一次嘗試 –