map: various small fixes

This commit is contained in:
Nils Schneider 2015-07-07 21:42:55 +02:00
parent 02a03e5a61
commit ec49c9d59b

View file

@ -198,11 +198,6 @@ define(["map/clientlayer", "map/labelslayer",
layerControl.addBaseLayer(layer, layerName) layerControl.addBaseLayer(layer, layerName)
customLayers.add(layerName) customLayers.add(layerName)
if (!layerControl.added) {
layerControl.addTo(map)
layerControl.added = true
}
if (localStorageTest()) if (localStorageTest())
localStorage.setItem("map/customLayers", JSON.stringify(Array.from(customLayers))) localStorage.setItem("map/customLayers", JSON.stringify(Array.from(customLayers)))
} catch (e) { } catch (e) {
@ -242,6 +237,7 @@ define(["map/clientlayer", "map/labelslayer",
})) }))
layerControl = L.control.layers(baseLayers, [], {position: "bottomright"}) layerControl = L.control.layers(baseLayers, [], {position: "bottomright"})
layerControl.addTo(map)
if (localStorageTest()) { if (localStorageTest()) {
var d = JSON.parse(localStorage.getItem("map/customLayers")) var d = JSON.parse(localStorage.getItem("map/customLayers"))
@ -277,7 +273,8 @@ define(["map/clientlayer", "map/labelslayer",
} }
function resetZoom() { function resetZoom() {
setView(barycenter.getBounds()) if (barycenter)
setView(barycenter.getBounds())
} }
function goto(m) { function goto(m) {
@ -321,6 +318,10 @@ define(["map/clientlayer", "map/labelslayer",
function calcBarycenter(nodes) { function calcBarycenter(nodes) {
nodes = nodes.map(function (d) { return d.nodeinfo.location }) nodes = nodes.map(function (d) { return d.nodeinfo.location })
if (nodes.length === 0)
return undefined
var lats = nodes.map(function (d) { return d.latitude }) var lats = nodes.map(function (d) { return d.latitude })
var lngs = nodes.map(function (d) { return d.longitude }) var lngs = nodes.map(function (d) { return d.longitude })