2015-10-05 66 views
3

我試圖將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(); 

仍然沒有工作

回答

0

你有沒有嘗試將editable: true添加到您的默認值?

angular.extend($scope, { 
    defaults: { 
     editable: true 
    }, 
    center: { 
     lat: 51.505, 
     lng: -0.09, 
     zoom: 8 
    } 
}); 

<leaflet defaults="defaults" lf-center="center" height="480px" width="640px"></leaflet> 
+0

嘗試,失敗:( –

+0

您可以驗證,如果它真的通過檢查設置您的地圖實例的選項對象:'console.log(map.options.editable);' – iH8

+0

將editable屬性添加到默認值根本不起作用。我已經用我的la更新了這個問題第一次嘗試 –

0

對於任何人都希望像我這樣做現有的地圖編輯

var map = L.map('map', {editable: true}); 

相同

var map = L.map('map'); 
map.editTools = new L.Editable(map);