Merge pull request #3048 from CloudNiner/feature/fix-2318
Closes #2318: getMaxZoom returns prev layer on baselayerchange
This commit is contained in:
commit
e5ee31d6b5
@ -202,6 +202,8 @@ L.Control.Layers = L.Control.extend({
|
|||||||
_onInputClick: function () {
|
_onInputClick: function () {
|
||||||
var inputs = this._form.getElementsByTagName('input'),
|
var inputs = this._form.getElementsByTagName('input'),
|
||||||
input, layer, hasLayer;
|
input, layer, hasLayer;
|
||||||
|
var addedLayers = [],
|
||||||
|
removedLayers = [];
|
||||||
|
|
||||||
this._handlingClick = true;
|
this._handlingClick = true;
|
||||||
|
|
||||||
@ -211,13 +213,21 @@ L.Control.Layers = L.Control.extend({
|
|||||||
hasLayer = this._map.hasLayer(layer);
|
hasLayer = this._map.hasLayer(layer);
|
||||||
|
|
||||||
if (input.checked && !hasLayer) {
|
if (input.checked && !hasLayer) {
|
||||||
this._map.addLayer(layer);
|
addedLayers.push(layer);
|
||||||
|
|
||||||
} else if (!input.checked && hasLayer) {
|
} else if (!input.checked && hasLayer) {
|
||||||
this._map.removeLayer(layer);
|
removedLayers.push(layer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bugfix issue 2318: Should remove all old layers before readding new ones
|
||||||
|
for (i = 0; i < removedLayers.length; i++) {
|
||||||
|
this._map.removeLayer(removedLayers[i]);
|
||||||
|
}
|
||||||
|
for (i = 0; i < addedLayers.length; i++) {
|
||||||
|
this._map.addLayer(addedLayers[i]);
|
||||||
|
}
|
||||||
|
|
||||||
this._handlingClick = false;
|
this._handlingClick = false;
|
||||||
|
|
||||||
this._refocusOnMap();
|
this._refocusOnMap();
|
||||||
|
Loading…
Reference in New Issue
Block a user