ui-leaflet icon indicating copy to clipboard operation
ui-leaflet copied to clipboard

Unknown layer in overlays list

Open mahmoudmy opened this issue 8 years ago • 4 comments

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.

mahmoudmy avatar Aug 31 '16 05:08 mahmoudmy

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

nmccready avatar Aug 31 '16 16:08 nmccready

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

mahmoudmy avatar Sep 01 '16 05:09 mahmoudmy

+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);
		}

hyungouk avatar Feb 14 '17 00:02 hyungouk

check #333 there's a workaround

matalaa avatar May 20 '19 22:05 matalaa