From ec49c9d59bb112840846ff4ccff67620d5d63371 Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Tue, 7 Jul 2015 21:42:55 +0200 Subject: [PATCH] map: various small fixes --- lib/map.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/map.js b/lib/map.js index 8e7bcc8..66ead33 100644 --- a/lib/map.js +++ b/lib/map.js @@ -198,11 +198,6 @@ define(["map/clientlayer", "map/labelslayer", layerControl.addBaseLayer(layer, layerName) customLayers.add(layerName) - if (!layerControl.added) { - layerControl.addTo(map) - layerControl.added = true - } - if (localStorageTest()) localStorage.setItem("map/customLayers", JSON.stringify(Array.from(customLayers))) } catch (e) { @@ -242,6 +237,7 @@ define(["map/clientlayer", "map/labelslayer", })) layerControl = L.control.layers(baseLayers, [], {position: "bottomright"}) + layerControl.addTo(map) if (localStorageTest()) { var d = JSON.parse(localStorage.getItem("map/customLayers")) @@ -277,7 +273,8 @@ define(["map/clientlayer", "map/labelslayer", } function resetZoom() { - setView(barycenter.getBounds()) + if (barycenter) + setView(barycenter.getBounds()) } function goto(m) { @@ -321,6 +318,10 @@ define(["map/clientlayer", "map/labelslayer", function calcBarycenter(nodes) { 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 lngs = nodes.map(function (d) { return d.longitude })