mirror of
https://github.com/Leaflet/Leaflet.git
synced 2025-08-20 14:34:38 +00:00
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:
@ -271,6 +271,10 @@ L.Map = L.Class.extend({
|
|||||||
return Math.min(z1, z2);
|
return Math.min(z1, z2);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getZoomLevels: function () {
|
||||||
|
return this.getMaxZoom() - this.getMinZoom() + 1;
|
||||||
|
},
|
||||||
|
|
||||||
getBoundsZoom: function (bounds, inside) { // (LatLngBounds, Boolean) -> Number
|
getBoundsZoom: function (bounds, inside) { // (LatLngBounds, Boolean) -> Number
|
||||||
bounds = L.latLngBounds(bounds);
|
bounds = L.latLngBounds(bounds);
|
||||||
|
|
||||||
@ -533,7 +537,8 @@ L.Map = L.Class.extend({
|
|||||||
_updateZoomLevels: function () {
|
_updateZoomLevels: function () {
|
||||||
var i,
|
var i,
|
||||||
minZoom = Infinity,
|
minZoom = Infinity,
|
||||||
maxZoom = -Infinity;
|
maxZoom = -Infinity,
|
||||||
|
oldZoomLevels = this.getZoomLevels();
|
||||||
|
|
||||||
for (i in this._zoomBoundLayers) {
|
for (i in this._zoomBoundLayers) {
|
||||||
if (this._zoomBoundLayers.hasOwnProperty(i)) {
|
if (this._zoomBoundLayers.hasOwnProperty(i)) {
|
||||||
@ -553,6 +558,10 @@ L.Map = L.Class.extend({
|
|||||||
this._layersMaxZoom = maxZoom;
|
this._layersMaxZoom = maxZoom;
|
||||||
this._layersMinZoom = minZoom;
|
this._layersMinZoom = minZoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (oldZoomLevels !== this.getZoomLevels()) {
|
||||||
|
this.fire("zoomlevelschange");
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// map events
|
// map events
|
||||||
|
Reference in New Issue
Block a user