the bug layer should autmatically download when panning. Move the loading/parsing...
[potlatch2.git] / net / systemeD / potlatch2 / utils / BugLoader.as
index de24af6a11f9ca2f23587144370367f737402150..bebd7db7a3b5db0a1cf5bff92d4da9948fc478fd 100644 (file)
@@ -6,7 +6,6 @@ package net.systemeD.potlatch2.utils {
     import net.systemeD.potlatch2.BugLayer;
     import flash.net.*;
     import flash.events.*;
     import net.systemeD.potlatch2.BugLayer;
     import flash.net.*;
     import flash.events.*;
-    import com.adobe.serialization.json.JSON;
     import flash.system.Security;
 
     public class BugLoader {
     import flash.system.Security;
 
     public class BugLoader {
@@ -17,6 +16,7 @@ package net.systemeD.potlatch2.utils {
         private var _layer:VectorLayer;
         private static const STYLESHEET:String="bugs.css";
 
         private var _layer:VectorLayer;
         private static const STYLESHEET:String="bugs.css";
 
+
         public function BugLoader(map:Map, url:String, bugApiKey:String):void {
             this.map = map;
             this.bugBaseURL = url;
         public function BugLoader(map:Map, url:String, bugApiKey:String):void {
             this.map = map;
             this.bugBaseURL = url;
@@ -26,37 +26,9 @@ package net.systemeD.potlatch2.utils {
         }
 
         public function load():void {
         }
 
         public function load():void {
-            var loader:URLLoader = new URLLoader();
-            loader.load(new URLRequest(bugBaseURL+"getBugs?bbox="+map.edge_l+","+map.edge_b+","+map.edge_r+","+map.edge_t+"&key="+bugApiKey));
-            loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, balls);
-            loader.addEventListener(Event.COMPLETE, parseJSON);
-        }
-
-        public function balls(event:SecurityErrorEvent):void {
-            trace(event);
+            layer.loadBbox(map.edge_l, map.edge_r, map.edge_t, map.edge_b);
         }
 
         }
 
-        private function parseJSON(event:Event):void {
-            var result:String = String(event.target.data);
-            var featureCollection:Object = JSON.decode(result);
-
-            for each (var feature:Object in featureCollection.features) {
-              // geoJSON spec is x,y,z i.e. lon, lat, ele
-              var lon:Number = feature.geometry.coordinates[0];
-              var lat:Number = feature.geometry.coordinates[1];
-              var tags:Object = {};
-              tags["name"] = String(feature.properties.description).substr(0,10)+'...';
-              tags["description"] = feature.properties.description;
-              tags["bug_id"] = feature.id;
-              tags["nickname"] = feature.properties.nickname;
-              tags["type"] = feature.properties.type;
-              tags["date_created"] = feature.properties.date_created;
-              tags["date_updated"] = feature.properties.date_updated;
-              tags["source"] = feature.properties.source;
-              var marker:Marker = layer.createMarker(tags, lat, lon);
-            }
-            layer.paint.updateEntityUIs(layer.getObjectsByBbox(map.edge_l,map.edge_r,map.edge_t,map.edge_b), true, false);
-        }
 
         private function get layer():VectorLayer {
             if (!_layer) {
 
         private function get layer():VectorLayer {
             if (!_layer) {