]> git.openstreetmap.org Git - potlatch2.git/blobdiff - net/systemeD/potlatch2/utils/BugLoader.as
Refactor BugLayer to extend connection, and rename it to BugConnection to save confusion
[potlatch2.git] / net / systemeD / potlatch2 / utils / BugLoader.as
index 5b70251f131f92fbaf7e35b2eab566ce4ca53bb5..34ca32a84e7c8c01572f2d2969f49a406373cc41 100644 (file)
@@ -1,9 +1,9 @@
 package net.systemeD.potlatch2.utils {
 
     import net.systemeD.halcyon.Map;
 package net.systemeD.potlatch2.utils {
 
     import net.systemeD.halcyon.Map;
-    import net.systemeD.halcyon.VectorLayer;
+    import net.systemeD.halcyon.MapPaint;
     import net.systemeD.halcyon.connection.Marker;
     import net.systemeD.halcyon.connection.Marker;
-    import net.systemeD.potlatch2.BugLayer;
+    import net.systemeD.potlatch2.BugConnection;
     import flash.net.*;
     import flash.events.*;
     import flash.system.Security;
     import flash.net.*;
     import flash.events.*;
     import flash.system.Security;
@@ -14,9 +14,10 @@ package net.systemeD.potlatch2.utils {
         private var bugBaseURL:String;
         private var bugApiKey:String;
         private var bugDetailsURL:String;
         private var bugBaseURL:String;
         private var bugApiKey:String;
         private var bugDetailsURL:String;
-        private var _layer:VectorLayer;
+        private var _layer:MapPaint;
         private var name:String;
         private static const STYLESHEET:String="stylesheets/bugs.css";
         private var name:String;
         private static const STYLESHEET:String="stylesheets/bugs.css";
+        private var connection:BugConnection;
 
 
         public function BugLoader(map:Map, url:String, bugApiKey:String, name:String, details:String = ''):void {
 
 
         public function BugLoader(map:Map, url:String, bugApiKey:String, name:String, details:String = ''):void {
@@ -25,23 +26,24 @@ package net.systemeD.potlatch2.utils {
             this.bugApiKey = bugApiKey;
             this.name = name;
             this.bugDetailsURL = details;
             this.bugApiKey = bugApiKey;
             this.name = name;
             this.bugDetailsURL = details;
+            connection = new BugConnection(name, url, bugApiKey, details);
         }
 
         public function load():void {
         }
 
         public function load():void {
-            layer.loadBbox(map.edge_l, map.edge_r, map.edge_t, map.edge_b);
+            connection.loadBbox(map.edge_l, map.edge_r, map.edge_t, map.edge_b);
+            // FIXME Note this fires too early, since loadBbox is asynchronous
+            layer.updateEntityUIs(true, false);
         }
 
         }
 
+        private function get layer():MapPaint {
+            if (!_layer) {
+                // should be done by the connection
+                var policyFile:String = bugBaseURL+"crossdomain.xml";
+                Security.loadPolicyFile(policyFile);
 
 
-        private function get layer():VectorLayer {
-                       // >>>> REFACTOR: VectorLayer commented out
-            // if (!_layer) {
-            //     var policyFile:String = bugBaseURL+"crossdomain.xml";
-            //     Security.loadPolicyFile(policyFile);
-            //     _layer=new BugLayer(name,map,STYLESHEET,bugBaseURL,bugApiKey,bugDetailsURL);
-            //     map.addVectorLayer(_layer);
-            // }
-            // return _layer;
-                       return null;
+                _layer = map.addLayer(connection, STYLESHEET);
+            }
+            return _layer;
         }
     }
 }
\ No newline at end of file
         }
     }
 }
\ No newline at end of file