Support importing the <create> element only of <osmChange> files
[potlatch2.git] / net / systemeD / potlatch2 / utils / BikeShopConnection.as
1 package net.systemeD.potlatch2.utils {
2
3     import net.systemeD.halcyon.connection.Connection;
4     import net.systemeD.halcyon.connection.Marker;
5     import com.adobe.serialization.json.JSON;
6     import flash.system.Security;
7     import flash.net.*;
8     import flash.events.*;
9
10     public class BikeShopConnection extends Connection {
11
12         public function BikeShopConnection(cname:String,api:String,policy:String,initparams:Object=null) {
13             super(cname,api,policy,initparams);
14         }
15
16         public override function loadBbox(left:Number, right:Number, top:Number, bottom:Number):void {
17
18             // Should be guarded against multiple calls really.
19             if (policyURL != "") { Security.loadPolicyFile(policyURL); }
20
21             var loader:URLLoader = new URLLoader();
22             loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, balls);
23             loader.addEventListener(Event.COMPLETE, parseKML);
24             loader.load(new URLRequest(apiBaseURL+"shop/missing.kml?bbox="+left+","+bottom+","+right+","+top));
25         }
26
27         public function balls(event:SecurityErrorEvent):void {
28         }
29
30         private function parseKML(event:Event):void {
31             //trace(event.target.data);
32             default xml namespace = new Namespace("http://www.opengis.net/kml/2.2");
33             var kml:XML = new XML(event.target.data);
34             //trace(kml.attributes());
35             //var document:XMLList = kml.Document;
36             for each (var placemark:XML in kml..Placemark) {
37               trace("name:"+placemark.name);
38               var coords:Array = placemark..coordinates.split(",");
39               var lon:Number = coords[0];
40               var lat:Number = coords[1];
41               //var ele:Number = coords[2];
42               var tags:Object = {};
43               tags["name"] = String(placemark.name);
44               tags["description"] = String(placemark.description);
45               var marker:Marker = createMarker(tags, lat, lon);
46             }
47             default xml namespace = new Namespace("");
48         }
49     }
50 }