Limit map to the maximum zoom of the current base layer

Fix maximum zoom levels for various layers and ensure that the
map can't be zoomed beyond the limit of the current base layer.

Fixes #1978
This commit is contained in:
Tom Hughes 2018-09-10 20:37:36 +01:00
parent 297b0a0e16
commit a7cdb0298d
2 changed files with 10 additions and 1 deletions

View file

@ -61,6 +61,12 @@ L.OSM.Map = L.Map.extend({
code: "G",
name: I18n.t("javascripts.map.base.gps")
});
this.on("layeradd", function (event) {
if (this.baseLayers.indexOf(event.layer) >= 0) {
this.setMaxZoom(event.layer.options.maxZoom);
}
});
},
updateLayers: function(layerParam) {