angular-ui / ui-leaflet

AngularJS directive to embed an interact with maps managed by Leaflet library
http://angular-ui.github.io/ui-leaflet
Other
314 stars 134 forks source link

Unknown layer in overlays list #287

Open mahmoudmy opened 8 years ago

mahmoudmy commented 8 years ago

I recently updated to version (1.0.1). But in the layers menu there is an unknown layer named toNumber. In the controller I didn't define any overlays!

tonumber

There isn't any error or log in browser's console.

nmccready commented 8 years ago

What does your layer config look like? Can you make a jsbin or plnkr?

mahmoudmy commented 8 years ago

This is my map config in the controller:

angular.extend($scope, {
      center: {
        lat: 31.91,
        lng: 54.31,
        zoom: 7
      },
      events: {},
      layers: {
        baselayers: {
          OSM: {
            name: 'OSM',
            url: 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
            type: 'xyz'
          },
          Bing: {
            name: 'Bing',
            type: 'bing',
            key: 'Aj6XtE1Q1rIvedmjn2Rh1Lj2qvMhZ-8vPS9HnfjCeUiToM77JFnf-kFRzyMELDol',
            layerOptions: {
              type: 'AerialWithLabels'
            }
          }
        },
        overlays: {}
      },
      defaults: {
        scrollWheelZoom: false
      }
    });

and in the tempalte:

<leaflet layers="layers" geojson="geojson" defaults="defaults" lf-center="center" height="300px" width="100%"></leaflet>

@nmccready

hyungouk commented 7 years ago

+1

and I just figured out why. it is because the layer control initialization loops the overlays and baseLayers with for(var i in -) loop. so. if you have Array.prototype.toNumber declared somewhere, it will be enumerated.

        for (var i in baseLayers) {
            this._addLayer(baseLayers[i], i);
        }

        for (i in overlays) {
            this._addLayer(overlays[i], i, true);
        }
matalaa commented 5 years ago

check #333 there's a workaround