Add floating imagery window
[potlatch2.git] / potlatch2.mxml
index 5fbe9cb0afdb0806e744617c9fb2716820707715..36dac00824e623b6d4618f29c7d3f3ae7cebc440 100644 (file)
         public var theController:EditController;
                public var trackLoader:TrackLoader;
                public var toolbox:Toolbox;
+               public var floatingMap:FloatingMap;
         public var bugLoader:BugLoader;
         public var bikeShopLoader:BikeShopLoader;
 
                        for (k in SharedObject.getLocal('user_state',"/").data) params[k]=SharedObject.getLocal('user_state',"/").data[k];
 
                        // Create map
-                       theMap=new Map();
+                       var overlay:Sprite=TileSet.overlaySprite();
+                       theMap=new Map(overlay);
                        theMap.backdrop=b;
             theMap.updateSize(w,h);
                        theMap.addEventListener(MapEvent.SCALE, scaleHandler);
                        _root.addChild(theMap);
+                       _root.addChild(overlay);
 
                        // Initialise stylesheets
                        Stylesheets.instance().init();
                        //           until the user has decided where to start editing (e.g. when the first GPX loads)
                        theMap.init(params['lat'], params['lon'], params['zoom']);
 
-                       // add attribution/logo sprite
-                       var overlay:Sprite=new Sprite();
-                       var attribution:TextField=new TextField();
-                       attribution.width=220; attribution.height=300;
-                       attribution.multiline=true;
-                       attribution.wordWrap=true;
-                       attribution.selectable=false;
-                       attribution.defaultTextFormat=new TextFormat("_sans", 9, 0, false, false, false);
-                       overlay.addChild(attribution);
-                       var terms:TextField=new TextField();
-                       terms.width=200; terms.height=15;
-                       terms.selectable=false;
-                       terms.defaultTextFormat=new TextFormat("_sans", 9, 0, false, false, true);
-                       overlay.addChild(terms);
-                       _root.addChild(overlay);
-
                        // mouse-up handler attached to stage, so the user can release outside the map
                        stage.addEventListener(MouseEvent.MOUSE_UP, theMap.mouseUpHandler);
                        Globals.vars.map_area.addEventListener(MouseEvent.MOUSE_MOVE, theMap.mouseMoveHandler);
                        theMap.tileset.setDimming(params['background_dim']    ==null ? true  : params['background_dim']);
                        theMap.tileset.setSharpen(params['background_sharpen']==null ? false : params['background_sharpen']);
                        var imagery:Imagery = Imagery.instance();
-                       imagery.init(theMap, overlay);
+                       imagery.init();
+                       theMap.tileset.init(imagery.selected, imagery.selected != '');
                        imagery.addEventListener(MapEvent.BUMP, bumpHandler);
                        imagery.addEventListener(CollectionEvent.SELECT,
-                               function(e:CollectionEvent):void { theMap.tileset.init(e.data, e.data!=''); }
+                               function(e:CollectionEvent):void { 
+                                       theMap.tileset.setBackgroundFromImagery(e.data,false);
+                               }
                        );
-                       theMap.tileset.init(imagery.selected, imagery.selected != '');
+                       imagery.addEventListener('imageryLoaded',function(e:Event):void {
+                               // Tell the function key manager that we'd like to receive function key calls
+                               FunctionKeyManager.instance().registerListener('Background imagery',
+                                       function(o:String):void { theMap.tileset.setBackgroundFromImagery(imagery.findBackgroundWithName(o),true); });
+                               dispatchEvent(new Event("collection_changed"));
+                       });
+                       imagery.addEventListener('refreshAttribution',function(e:Event):void {
+                               theMap.tileset.setLogo(); theMap.tileset.setAttribution(); theMap.tileset.setTerms(); 
+                       });
                        
                        // keyboard event attached to stage
                        stage.addEventListener(KeyboardEvent.KEY_UP, theMap.keyUpHandler);
                        theController.addEventListener(AttentionEvent.ATTENTION, onAttention);
                        theController.addEventListener(AttentionEvent.ALERT, onAlert);
                        theController.addEventListener(EditController.CHANGED_STATE, onStateChanged);
-            
+
+                       // add floating map
+                       floatingMap=FloatingMap(PopUpManager.createPopUp(this,FloatingMap,false));
+                       floatingMap.visible=false;
+                       floatingMap.init(theController);
+                       floatingMap.x=stage.stageWidth-410;
+                       floatingMap.y=36;
+
             // set the access token from saved cookie
             var tokenObject:SharedObject = SharedObject.getLocal("access_token","/");
             conn.setAccessToken(tokenObject.data["oauth_token"], tokenObject.data["oauth_token_secret"]);