From fa9a29e0facf7e8dd93714cfa197c9c0ef2d349e Mon Sep 17 00:00:00 2001 From: Marvin W Date: Sun, 22 May 2016 12:30:31 +0200 Subject: [PATCH] [TASK] Dynamically select maxLayerZoom Fixes clients/names being hidden accidentally (in certain conditions). Also added auto-zoom-out to ensure zoom is in bounds --- lib/map.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/map.js b/lib/map.js index 90b020f..6515fd0 100644 --- a/lib/map.js +++ b/lib/map.js @@ -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})); }