Allow pubs to be given names.
[potlatch2.git] / potlatch2.mxml
index d71d38b222c5bf223d373181d4469ca38d79da37..0ed126352b574ea8fb59740d0abbe2b3ca4f9b6b 100755 (executable)
     <mx:WipeRight id="wipeIn" duration="250"/>
 
     <mx:ApplicationControlBar dock="true">
     <mx:WipeRight id="wipeIn" duration="250"/>
 
     <mx:ApplicationControlBar dock="true">
+        <mx:PopUpButton id="bgButton" label="Background" openAlways="true"
+            creationComplete="bgButton.popUp = new BackgroundSelector();"/>
+        <mx:PopUpButton id="styleButton" label="Map Style" openAlways="true"
+            creationComplete="styleButton.popUp = new StyleSelector();"/>
         <mx:Spacer width="100%"/>
         <mx:Spacer width="100%"/>
+        <mx:Button label="Help" click="new HelpDialog().init();" />
+        <mx:Button label="Options" click="new OptionsDialog().init();" />
         <mx:Button label="Save" icon="@Embed('embedded/save.svg')" click="SaveManager.saveChanges();"/>
     </mx:ApplicationControlBar>
     
     <mx:HDividedBox width="100%" height="100%">
 
         <mx:Button label="Save" icon="@Embed('embedded/save.svg')" click="SaveManager.saveChanges();"/>
     </mx:ApplicationControlBar>
     
     <mx:HDividedBox width="100%" height="100%">
 
-      <mx:VBox height="100%" width="25%" horizontalAlign="right">
-        <potlatch2:TagViewer width="100%" height="100%" id="tagViewer"/>
-      </mx:VBox>
+         <!-- Tag viewer -->
+         <potlatch2:TagViewer width="25%" height="100%" id="tagViewer"/>
+
       <mx:Canvas width="75%" height="100%">
         <mx:Canvas id="map_area" resize="onResizeMap()"
       <mx:Canvas width="75%" height="100%">
         <mx:Canvas id="map_area" resize="onResizeMap()"
-            top="0" left="0" width="100%" height="100%">
+            top="0" left="0" width="100%" height="100%" dragEnter="dragEnterHandler(event);" dragDrop="dragDropHandler(event);">
         </mx:Canvas>
         <mx:Image source="@Embed('embedded/zoomIn.svg')" right="3" top="3" click="theMap.zoomIn();"
             rollOverEffect="glowImage" rollOutEffect="unglowImage"/>
         </mx:Canvas>
         <mx:Image source="@Embed('embedded/zoomIn.svg')" right="3" top="3" click="theMap.zoomIn();"
             rollOverEffect="glowImage" rollOutEffect="unglowImage"/>
                import net.systemeD.halcyon.connection.*;
                import net.systemeD.potlatch2.*;
                import net.systemeD.potlatch2.save.SaveManager;
                import net.systemeD.halcyon.connection.*;
                import net.systemeD.potlatch2.*;
                import net.systemeD.potlatch2.save.SaveManager;
+               import net.systemeD.potlatch2.help.*;
+               import net.systemeD.potlatch2.options.*;
+               import net.systemeD.potlatch2.utils.*;
+               import mx.managers.PopUpManager;
                import flash.system.Security;
                import flash.net.*;
                import flash.events.MouseEvent;
                import flash.system.Security;
                import flash.net.*;
                import flash.events.MouseEvent;
                import com.yahoo.maps.api.YahooMap;
                import com.yahoo.maps.api.YahooMapEvent;
                import com.yahoo.maps.api.core.location.LatLon;
                import com.yahoo.maps.api.YahooMap;
                import com.yahoo.maps.api.YahooMapEvent;
                import com.yahoo.maps.api.core.location.LatLon;
+        import mx.events.DragEvent;
+        import mx.managers.DragManager;
+        import mx.core.DragSource;
 
         public var theMap:Map;
 
         public var theMap:Map;
+               public var yahooListener:Object = new Object();
+               public var yahoo:YahooMap = new YahooMap(); 
 
                private function initApp():void {
 
 
                private function initApp():void {
 
-                       Globals.vars.map_area=map_area;
-                       Globals.vars.root=map_area.rawChildren;                 // set up global reference to root level
-                       var _root:IChildList=map_area.rawChildren;              // convenient local shorthand
+                       Globals.vars.map_area = map_area;
+                       Globals.vars.yahoo = yahoo;
+                       Globals.vars.root = map_area.rawChildren;                       // set up global reference to root level
+                       var _root:IChildList = map_area.rawChildren;            // convenient local shorthand
 
                        // map backdrop object
             var w:uint = map_area.width;
 
                        // map backdrop object
             var w:uint = map_area.width;
             b.graphics.endFill();
                        _root.addChild(b);
 
             b.graphics.endFill();
                        _root.addChild(b);
 
-/*                     // Add Yahoo! background
-                       var yahoo:YahooMap = new YahooMap(); 
+                       // Add Yahoo! background
                        yahoo.init("f0a.sejV34HnhgIbNSmVHmndXFpijgGeun0fSIMG9428hW_ifF3pYKwbV6r9iaXojl1lU_dakekR", w, h);  
                        yahoo.mapType="satellite";
                        _root.addChild(yahoo);
                        yahoo.init("f0a.sejV34HnhgIbNSmVHmndXFpijgGeun0fSIMG9428hW_ifF3pYKwbV6r9iaXojl1lU_dakekR", w, h);  
                        yahoo.mapType="satellite";
                        _root.addChild(yahoo);
+                       yahoo.visible=false;
+                       yahoo.alpha=0.5;
 
                        // Yahoo! listeners
 
                        // Yahoo! listeners
-                       var yahooListener:Object = new Object();
                        yahooListener.yahooInit=function(event:YahooMapEvent):void {
                                yahoo.zoomLevel = 18-theMap.scale;
                                yahoo.centerLatLon = new LatLon(theMap.centre_lat, theMap.centre_lon);
 
                                yahooListener.moveHandler=function(event:MapEvent):void {
                        yahooListener.yahooInit=function(event:YahooMapEvent):void {
                                yahoo.zoomLevel = 18-theMap.scale;
                                yahoo.centerLatLon = new LatLon(theMap.centre_lat, theMap.centre_lon);
 
                                yahooListener.moveHandler=function(event:MapEvent):void {
+                                       if (!yahoo.visible) { return; }
                                        yahoo.zoomLevel=18-event.params.scale;
                                        yahoo.centerLatLon=new LatLon(event.params.lat, event.params.lon);
                                };
                                        yahoo.zoomLevel=18-event.params.scale;
                                        yahoo.centerLatLon=new LatLon(event.params.lat, event.params.lon);
                                };
                                theMap.addEventListener(MapEvent.RESIZE, yahooListener.resizeHandler);
                        }
                        yahoo.addEventListener(YahooMapEvent.MAP_INITIALIZE, yahooListener.yahooInit);
                                theMap.addEventListener(MapEvent.RESIZE, yahooListener.resizeHandler);
                        }
                        yahoo.addEventListener(YahooMapEvent.MAP_INITIALIZE, yahooListener.yahooInit);
-*/
+
                        // add map
                        theMap=new Map(this.loaderInfo.parameters);
                        theMap.backdrop=b;
                        // add map
                        theMap=new Map(this.loaderInfo.parameters);
                        theMap.backdrop=b;
             var conn:Connection = Connection.getConnectionInstance();
             conn.addEventListener(Connection.LOAD_STARTED, onDataStart);
             conn.addEventListener(Connection.LOAD_COMPLETED, onDataComplete);
             var conn:Connection = Connection.getConnectionInstance();
             conn.addEventListener(Connection.LOAD_STARTED, onDataStart);
             conn.addEventListener(Connection.LOAD_COMPLETED, onDataComplete);
+
+                       // and to import a shapefile...
+//                     var importer:ShpImporter = new ShpImporter(theMap, ["http://127.0.0.1/~richard/shp/wildrnp020.shp","http://127.0.0.1/~richard/shp/wildrnp020.shx","http://127.0.0.1/~richard/shp/wildrnp020.dbf"]);
                }
 
         public function onResizeMap():void {
                }
 
         public function onResizeMap():void {
         private function onDataComplete(event:Event):void {
             dataWorking.visible = false;
         }
         private function onDataComplete(event:Event):void {
             dataWorking.visible = false;
         }
+        
+
+        
+        private function dragEnterHandler(event:DragEvent):void {
+            // Get the drop target component from the event object.
+            var dropTarget:Canvas=event.currentTarget as Canvas;
+            // Accept the drag only if the user is dragging poi with tags
+            if (event.dragSource.hasFormat('tags')) 
+            {
+                DragManager.acceptDragDrop(dropTarget);
+            }
+        }
+        
+        private function dragDropHandler(event:DragEvent):void {
+            // Get the data identified by the color format from the drag source.
+            // Blame http://www.adobe.com/devnet/flex/quickstart/adding_drag_and_drop/#manual
+            // for whatever horrid abuse of "color format" this is doing
+            var tags:Array = event.dragSource.dataForFormat('tags') as Array;
+            var mapLoc:Point = Globals.vars.root.globalToLocal(new Point(event.stageX, event.stageY));
+            var lat:Number = Globals.vars.root.coord2lat(mapLoc.y);
+            var lon:Number = Globals.vars.root.coord2lon(mapLoc.x);
+            var node:Node = Connection.getConnectionInstance().createNode({}, lat, lon);
+            for each ( var tag:Object in tags ) {
+              node.setTag(tag.k, tag.v);
+            }
+                       Connection.getConnectionInstance().registerPOI(node);
+        }
+
        ]]></mx:Script>
 
 </mx:Application>
        ]]></mx:Script>
 
 </mx:Application>