2016-06-17 74 views
0

我正在嘗試爲角度實現這個非常簡單的傳單指令。 (完整代碼是https://github.com/pluess/woodstore)。簡單的角度傳單指令在啓動時失敗

class MapDirective { 

    constructor() { 
     this.resctrict = 'E'; 
     this.controller = MapController; 
    } 

    link(scope, element) { 
     let map = L.map(element[0]).setView([30.70, -81.47], 12); 

     esri.tiledMapLayer({ 
      url: "https://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer" 
     }).addTo(map); 
    } 

    /** 
    * @returns {MapDirective} 
    */ 
    static directiveFactory() { 
     return new MapDirective(); 
    } 
} 

當我打開瀏覽器中我得到這個錯誤消息的應用程序:

angular.js:13708TypeError: Cannot read property 'getPane' of undefined 
    at NewClass.getPane (http://localhost:8080/bundle.js:60907:20) 
    at NewClass._initContainer (http://localhost:8080/bundle.js:61482:9) 
    at NewClass.onAdd (http://localhost:8080/bundle.js:61282:9) 
    at NewClass.onAdd (http://localhost:8080/bundle.js:55550:35) 
    at NewClass._layerAdd (http://localhost:8080/bundle.js:46600:10) 
    at NewClass.addLayer (http://localhost:8080/bundle.js:46058:10) 
    at NewClass.addTo (http://localhost:8080/bundle.js:60885:8) 
    at MapDirective.link (http://localhost:8080/bundle.js:44340:17) 
    at http://localhost:8080/bundle.js:14058:19 
    at invokeLinkFn (http://localhost:8080/bundle.js:22632:10) <map class="leaflet-container leaflet-fade-anim" tabindex="0" style="position: relative;"> 

任何想法是怎麼回事錯在這裏?

+0

哪裏getPane定義?它叫什麼名字?我沒有在你提供的鏈接上看到它。你需要提供更多的代碼讓我們弄清楚。 –

+0

'getPane'在小冊子代碼中:https://github.com/Leaflet/Leaflet/blob/master/src/layer/Layer.js#L66 – BetaRide

+0

您是否運行以下命令? 'npm install -g jake' 和'npm install' –

回答

0

事實證明,默認npm install esri-leaflet安裝版本2.0.0。這隻適用於尚處於測試階段的小冊子1.x。因此,解決辦法是改變

"esri-leaflet": "^2.0.0" 

"esri-leaflet": "^1.0.2"