Allow pubs to be given names.
[potlatch2.git] / potlatch2.mxml
index 9357df0923969e5608779612714c6415d851dbad..0ed126352b574ea8fb59740d0abbe2b3ca4f9b6b 100755 (executable)
@@ -40,7 +40,7 @@
 
       <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"/>
@@ -71,6 +71,9 @@
                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 yahooListener:Object = new Object();
         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>