Fire zoomlevelschange event when zoomlevels are updated.
This is triggered when you remove a layer from a map with greater zoom level coverage than the remainding layers or when you add a tilelayer with greater zoomlevel coverage than the previous set of layers had.
This commit is contained in:
parent
b8b8d7b351
commit
efe0c6f6ea
@ -271,6 +271,10 @@ L.Map = L.Class.extend({
|
||||
return Math.min(z1, z2);
|
||||
},
|
||||
|
||||
getZoomLevels: function () {
|
||||
return this.getMaxZoom() - this.getMinZoom() + 1;
|
||||
},
|
||||
|
||||
getBoundsZoom: function (bounds, inside) { // (LatLngBounds, Boolean) -> Number
|
||||
bounds = L.latLngBounds(bounds);
|
||||
|
||||
@ -533,7 +537,8 @@ L.Map = L.Class.extend({
|
||||
_updateZoomLevels: function () {
|
||||
var i,
|
||||
minZoom = Infinity,
|
||||
maxZoom = -Infinity;
|
||||
maxZoom = -Infinity,
|
||||
oldZoomLevels = this.getZoomLevels();
|
||||
|
||||
for (i in this._zoomBoundLayers) {
|
||||
if (this._zoomBoundLayers.hasOwnProperty(i)) {
|
||||
@ -553,6 +558,10 @@ L.Map = L.Class.extend({
|
||||
this._layersMaxZoom = maxZoom;
|
||||
this._layersMinZoom = minZoom;
|
||||
}
|
||||
|
||||
if (oldZoomLevels !== this.getZoomLevels()) {
|
||||
this.fire("zoomlevelschange");
|
||||
}
|
||||
},
|
||||
|
||||
// map events
|
||||
|
Loading…
Reference in New Issue
Block a user