map: dynamically select maxLayerZoom (#27)
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:
parent
20f0f08de3
commit
9719385076
24
lib/map.js
24
lib/map.js
@ -290,12 +290,6 @@ define(["map/clientlayer", "map/labelslayer",
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
var maxLayerZoom = Math.max.apply(Math, config.mapLayers.map(
|
|
||||||
function(d) {
|
|
||||||
return (typeof d.config !== "undefined" && typeof d.config.maxZoom !== "undefined") ? d.config.maxZoom : 18
|
|
||||||
}))
|
|
||||||
|
|
||||||
|
|
||||||
layers[0].layer.addTo(map)
|
layers[0].layer.addTo(map)
|
||||||
|
|
||||||
layers.forEach( function (d) {
|
layers.forEach( function (d) {
|
||||||
@ -334,19 +328,23 @@ define(["map/clientlayer", "map/labelslayer",
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
map.on("baselayerchange", function(e) {
|
var clientLayer = new ClientLayer({minZoom: 15})
|
||||||
if (localStorageTest())
|
|
||||||
localStorage.setItem("map/selectedLayer", JSON.stringify({name: e.name}))
|
|
||||||
})
|
|
||||||
|
|
||||||
var clientLayer = new ClientLayer({minZoom: 15, maxZoom: maxLayerZoom})
|
|
||||||
clientLayer.addTo(map)
|
clientLayer.addTo(map)
|
||||||
clientLayer.setZIndex(5)
|
clientLayer.setZIndex(5)
|
||||||
|
|
||||||
var labelsLayer = new LabelsLayer({maxZoom: maxLayerZoom})
|
var labelsLayer = new LabelsLayer({})
|
||||||
labelsLayer.addTo(map)
|
labelsLayer.addTo(map)
|
||||||
labelsLayer.setZIndex(6)
|
labelsLayer.setZIndex(6)
|
||||||
|
|
||||||
|
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 (localStorageTest())
|
||||||
|
localStorage.setItem("map/selectedLayer", JSON.stringify({name: e.name}))
|
||||||
|
})
|
||||||
|
|
||||||
var nodeDict = {}
|
var nodeDict = {}
|
||||||
var linkDict = {}
|
var linkDict = {}
|
||||||
var highlight
|
var highlight
|
||||||
|
Loading…
Reference in New Issue
Block a user