Procházet zdrojové kódy

handle multiple setData calls in map

Nils Schneider před 9 roky
rodič
revize
0490455ccf
1 změnil soubory, kde provedl 17 přidání a 1 odebrání
  1. 17 1
      lib/map.js

+ 17 - 1
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))