Don't duplicate bugs. The complete reimplementation of Connection in VectorLayer...
authorAndy Allan <gravitystorm@gmail.com>
Wed, 24 Nov 2010 17:44:21 +0000 (17:44 +0000)
committerAndy Allan <gravitystorm@gmail.com>
Wed, 24 Nov 2010 17:44:21 +0000 (17:44 +0000)
TODO.txt
net/systemeD/halcyon/VectorLayer.as
net/systemeD/potlatch2/BugLayer.as

index f430415..c48dbcb 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -64,7 +64,6 @@ Potlatch 2: main outstanding issues
 * View comments and add new comments
 * Reopen?
 * Handle errors when closing bugs (especially nickname-based errors)
-* Multiple downloads create multiple copies of the same bug...
 
 Requested enhancements
 ----------------------
index 5ab6db9..b1640d4 100644 (file)
@@ -78,9 +78,25 @@ package net.systemeD.halcyon {
             return relation;
                }
 
-        public function createMarker(tags:Object,lat:Number,lon:Number):Marker {
-            var marker:Marker = new Marker(negativeID, 0, tags, true, lat, lon);
-            markers[negativeID]=marker; negativeID--;
+        /**
+        * Create a new Marker on the VectorLayer. If you pass in an id it'll check first whether that
+        * marker has been created already, and won't duplicate it.
+        *
+        * @param tags The tags for the new Marker
+        * @param lat The latitude
+        * @param lon The longitude
+        * @param id Use this id for the marker, useful for when layer might be reloaded during panning
+        */
+        public function createMarker(tags:Object,lat:Number,lon:Number,id:Number=NaN):Marker {
+            if (!id) {
+              id = negativeID;
+              negativeID--;
+            }
+            var marker:Marker = markers[id];
+            if (marker == null) {
+              marker = new Marker(id, 0, tags, true, lat, lon);
+              markers[id]=marker;
+            }
             return marker;
         }
 
index cfeb1d2..69dafc8 100644 (file)
@@ -67,7 +67,7 @@ package net.systemeD.potlatch2 {
                 tags["date_updated"] = feature.properties.date_updated;
                 tags["source"] = feature.properties.source;
                 tags["status"] = status[int(feature.properties.status)];
-                var marker:Marker = createMarker(tags, lat, lon);
+                var marker:Marker = createMarker(tags, lat, lon, Number(feature.id));
               }
               paint.updateEntityUIs(getObjectsByBbox(map.edge_l,map.edge_r,map.edge_t,map.edge_b), true, false);
             }