Angular Leaflet指令 - 重现图层示例

时间:2016-05-03 01:35:51

标签: angularjs ionic-framework leaflet angular-leaflet-directive

如何使用角度Leaflet指令重现this示例? 我理解这个例子,但是当我应用示例源的最后一行

L.control.layers(baseLayers, overlays).addTo(map);

我必须调整到

L.control.layers(baseLayers, overlays).addTo($scope);

因为现在所有地图属性都在$ scope中??

angular.extend($scope,{
                 defaults: {
                        layers: [streetLayer,sateliteLayer,oceanLayer],
                        maxZoom: 16,
                        zoomControl: false,
                        doubleClickZoom: true,
                        path: {
                            weight: 10,
                            color: '#800000',
                            opacity: 1
                        }
                 }
            });

我得到了

TypeError: this._map.on is not a function
    at o.Control.Layers.o.Control.extend._initLayout (leaflet.js:9)
    at o.Control.Layers.o.Control.extend.onAdd (leaflet.js:9)
    at o.Control.o.Class.extend.addTo (leaflet.js:9)
    at new <anonymous> (mapController.js:135)
    at invoke (ionic.bundle.js:12884)
    at Object.instantiate (ionic.bundle.js:12892)
    at ionic.bundle.js:17161
    at self.appendViewElement (ionic.bundle.js:48243)
    at Object.switcher.render (ionic.bundle.js:46441)
    at Object.switcher.init (ionic.bundle.js:46361)

0 个答案:

没有答案