From 0490455ccfb2dc6bf015b3a6f17050489df6fd2d Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Fri, 3 Apr 2015 00:02:00 +0200 Subject: [PATCH] handle multiple setData calls in map --- lib/map.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/map.js b/lib/map.js index 25feaef..93c442e 100644 --- a/lib/map.js +++ b/lib/map.js @@ -57,6 +57,7 @@ define(["d3", "leaflet", "moment", "leaflet.label"], function (d3, L, moment) { return function (config, linkScale, sidebar, router) { var self = this var barycenter + var groupOnline, groupOffline, groupNew, groupLost, groupLines var el = document.createElement("div") el.classList.add("map") @@ -94,8 +95,23 @@ define(["d3", "leaflet", "moment", "leaflet.label"], function (d3, L, moment) { nodeDict = {} linkDict = {} + if (groupOffline) + groupOffline.clearLayers() + + if (groupOnline) + groupOnline.clearLayers() + + if (groupNew) + groupNew.clearLayers() + + if (groupLost) + groupLost.clearLayers() + + if (groupLines) + groupLines.clearLayers() + var lines = addLinksToMap(linkDict, linkScale, data.graph.links, router) - L.featureGroup(lines).addTo(map) + groupLines = L.featureGroup(lines).addTo(map) barycenter = calcBarycenter(data.nodes.all.filter(has_location))