/**
* XMLConnection provides all the methods required to connect to a live
* OSM server. See OSMConnection for connecting to a read-only .osm file
+ *
+ * @see OSMConnection
*/
public class XMLConnection extends XMLBaseConnection {
+ /**
+ * Create a new XML connection
+ * @param name The name of the connection
+ * @param api The url of the OSM API server, e.g. http://api06.dev.openstreetmap.org/api/0.6/
+ * @param policy The url of the flash crossdomain policy to load,
+ e.g. http://api06.dev.openstreetmap.org/api/crossdomain.xml
+ * @param initparams Any further parameters for the connection, such as the serverName
+ */
public function XMLConnection(name:String,api:String,policy:String,initparams:Object) {
super(name,api,policy,initparams);
mapLoader.addEventListener(Event.COMPLETE, loadedMap);
mapLoader.addEventListener(IOErrorEvent.IO_ERROR, errorOnMapLoad);
mapLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS, mapLoadStatus);
+ request.requestHeaders.push(new URLRequestHeader("X-Error-Format", "XML"));
mapLoader.load(request);
dispatchEvent(new Event(LOAD_STARTED));
}
}
}
- private function tracesLoadComplete(event:Event):void {
- clearTraces();
- var files:XML = new XML(URLLoader(event.target).data);
- for each(var traceData:XML in files.gpx_file) {
- var t:Trace = new Trace(this).fromXML(traceData);
- addTrace(t);
- }
- traces_loaded = true;
- dispatchEvent(new Event(LOAD_COMPLETED));
- dispatchEvent(new Event(TRACES_LOADED));
- }
+ private function tracesLoadComplete(event:Event):void {
+ var files:XML = new XML(URLLoader(event.target).data);
+ for each(var traceData:XML in files.gpx_file) {
+ var t:Trace = findTrace(traceData.@id);
+ if (!t) { t=new Trace(this); addTrace(t); }
+ t.fromXML(traceData);
+ }
+ traces_loaded = true;
+ dispatchEvent(new Event(LOAD_COMPLETED));
+ dispatchEvent(new Event(TRACES_LOADED));
+ }
override public function fetchTrace(id:Number, callback:Function):void {
sendOAuthGet(apiBaseURL+"gpx/"+id+"/data.xml",