[TASK] Dynamically select maxLayerZoom

Fixes clients/names being hidden accidentally (in certain conditions). Also added auto-zoom-out to ensure zoom is in bounds
This commit is contained in:
Marvin W 2016-05-22 12:30:31 +02:00 committed by Xaver Maierhofer
parent ffbd9e0fbf
commit fa9a29e0fa
1 changed files with 4 additions and 4 deletions

View File

@ -301,12 +301,14 @@ define(["map/clientlayer", "map/labelslayer",
};
});
layers[0].layer.addTo(map);
layers.forEach(function (d) {
baseLayers[d.name] = d.layer;
});
map.on("locationfound", locationFound);
map.on("locationerror", locationError);
map.on("dragend", saveView);
@ -348,13 +350,11 @@ define(["map/clientlayer", "map/labelslayer",
labelsLayer.addTo(map);
labelsLayer.setZIndex(6);
map.on("baselayerchange", function (e) {
map.on("baselayerchange", function(e) {
map.options.maxZoom = e.layer.options.maxZoom;
clientLayer.options.maxZoom = map.options.maxZoom;
labelsLayer.options.maxZoom = map.options.maxZoom;
if (map.getZoom() > map.options.maxZoom) {
map.setZoom(map.options.maxZoom);
}
if (map.getZoom() > map.options.maxZoom) map.setZoom(map.options.maxZoom);
if (localStorageTest()) {
localStorage.setItem("map/selectedLayer", JSON.stringify({name: e.name}));
}