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))