this._layers = {};
this._lastZIndex = 0;
+ this._handlingClick = false;
for (var i in baseLayers) {
if (baseLayers.hasOwnProperty(i)) {
this._initLayout();
this._update();
+ map
+ .on('layeradd', this._update, this)
+ .on('layerremove', this._update, this);
+
return this._container;
},
+ onRemove: function (map) {
+ map
+ .off('layeradd', this._update)
+ .off('layerremove', this._update);
+ },
+
addBaseLayer: function (layer, name) {
this._addLayer(layer, name);
this._update();
},
_update: function () {
- if (!this._container) {
+ if (!this._container || this._handlingClick) {
return;
}
inputsLen = inputs.length,
baseLayer;
+ this._handlingClick = true;
+
for (i = 0; i < inputsLen; i++) {
input = inputs[i];
obj = this._layers[input.layerId];
if (baseLayer) {
this._map.fire('baselayerchange', {layer: baseLayer});
}
+
+ this._handlingClick = false;
},
_expand: function () {
-}(this));
\ No newline at end of file
+}(this));