Provide a new 'View data' button in the upload dialogue.
[potlatch2.git] / potlatch2.mxml
index d7744c2..9ad7000 100644 (file)
                        // >>>> REFACTOR: shouldn't be trying to find out stylesheet from here
                        theMap.addLayer(conn,params['styleurl'] ? params['styleurl'] : 'stylesheets/potlatch.css',false);
 
+            // Auto-load vector backgrounds from config
+            theMap.addEventListener(MapEvent.INITIALISED, function(e:Event):void { VectorBackgrounds.instance().init(theMap); });
+
                        // Set start position of map
                        // >>>> REFACTOR: what happens if lat/lon/zoom not supplied? (Hurleston GPX case)
                        theMap.init(params['lat'], params['lon'], params['zoom']);
 
-            // Auto-load vector backgrounds from config
-            // This could go spectacularly wrong if map.init completes before the event listener below is added
-            theMap.addEventListener(MapEvent.INITIALISED, function(e:Event):void { VectorBackgrounds.instance().init(theMap); });
-
                        // add attribution/logo sprite
                        var overlay:Sprite=new Sprite();
                        var attribution:TextField=new TextField();
 
             theController = new EditController(theMap, tagViewer, toolbox);
             theController.setActive();
+                       theController.addEventListener(AttentionEvent.ATTENTION, onAttention);
+                       theController.addEventListener(AttentionEvent.ALERT, onAlert);
             
             // set the access token from saved cookie
             var tokenObject:SharedObject = SharedObject.getLocal("access_token");
 
                        // Load arbitrary GPX from provided URL
                        if (loaderInfo.parameters['gpx_url']) {
-                               var vectorlayer:VectorLayer=new VectorLayer(name,theMap,"stylesheets/gpx.css");
-                               vectorlayer.url=loaderInfo.parameters['gpx_url'];
-                               var gpx:GpxImporter=new GpxImporter(vectorlayer, vectorlayer.paint, [vectorlayer.url], 
-                                                                   function(success:Boolean,message:String=null):void {
-                                       if (!success) return;
-                                       // >>>> REFACTOR: vectorlayer commented out
-//                                     theMap.addVectorLayer(vectorlayer);
-                                       dispatchEvent(new Event("layers_changed"));
-                                                                   }, false);
+
+                var gpx_url:String = loaderInfo.parameters['gpx_url'];
+
+                var connection:Connection = new Connection(name, gpx_url, null, null);
+                var gpx:GpxImporter=new GpxImporter(connection, theMap, [gpx_url],
+                                                function(success:Boolean,message:String=null):void {
+                                                    if (!success) return;
+                                                    var paint:MapPaint = theMap.addLayer(connection, "stylesheets/gpx.css");
+                                                    paint.updateEntityUIs(false, false);
+                                                    dispatchEvent(new Event("layers_changed"));
+                                                }, false);
                        }
 
                        // create GPS trackloader