Drag Drop icons loaded from map_features
authorAndy Allan <gravitystorm@gmail.com>
Sun, 28 Feb 2010 19:30:54 +0000 (19:30 +0000)
committerAndy Allan <gravitystorm@gmail.com>
Sun, 28 Feb 2010 19:30:54 +0000 (19:30 +0000)
TODO.txt
net/systemeD/potlatch2/TagViewer.mxml
net/systemeD/potlatch2/mapfeatures/MapFeatures.as
potlatch2.mxml

index fd4c98548a4290fd2906bf334a381f807f132ec4..2920d955a907ee69ccfcc59dddb0dd64784eedbe 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -11,7 +11,6 @@ Potlatch 2: main outstanding issues
 
 * Delete points and ways
 * Merge ways (almost there)
-* Drag-and-drop POIs
 * Undo/redo
 * Reverse way direction
 
index fe2278d79b46a24272b396f86611d21ead863cd4..6074d0e5a0acb1424927ab04c38006b37d51995b 100644 (file)
@@ -8,9 +8,32 @@
 <mx:ViewStack id="sidebar" width="100%" height="100%" creationPolicy="all">
   <mx:VBox id="dndPanel" width="100%" height="100%">
     <mx:Text text="Drag and Drop Points of Interest" />
-    <mx:Image id="pub" source="@Embed('../../../resources/icons/pub.png')" mouseMove="dragPOI(event, [['amenity','pub']])" />
-    <mx:Image id="station" source="@Embed('../../../resources/icons/station.png')"
-      mouseMove="dragPOI(event, [['railway', 'station'],['name','Charbury International']])" />
+    <mx:TileList id="poiGrid" dataProvider="{MapFeatures.getInstance().pois}" width="100%">
+      <mx:itemRenderer>
+        <mx:Component>
+          <mx:VBox>
+            <mx:Script><![CDATA[
+              import mx.events.DragEvent;
+              import mx.managers.DragManager;
+              import mx.core.DragSource;
+                  
+              private function dragPOI(event:MouseEvent, tags:Array):void {
+                  // Get the drag initiator component from the event object.
+                  var dragInitiator:Image = event.currentTarget as Image;
+                  var dragSource:DragSource = new DragSource();
+                  dragSource.addData(tags, 'tags');
+                  
+                  var dragProxy:Image = new Image();
+                  dragProxy.source = event.currentTarget.source;
+                  trace(dragProxy.source);
+                  DragManager.doDrag(dragInitiator, dragSource, event, dragProxy);
+              }
+            ]]></mx:Script>
+            <mx:Image id="foo" source="{data.image}" height="25" width="25" mouseMove="dragPOI(event, data.tags)"/>
+          </mx:VBox>
+        </mx:Component>
+      </mx:itemRenderer>
+    </mx:TileList>
   </mx:VBox>
   
   <mx:VBox id="tagsPanel" width="100%" height="100%">
index 92d72ea0312d3be8ecc0d06852584ae77cf7113d..1d92056112bb3f85ef1ade8a159699d255b95191 100644 (file)
@@ -105,6 +105,19 @@ package net.systemeD.potlatch2.mapfeatures {
             return _features;
         }
 
+        [Bindable(event="featuresLoaded")]
+        public function get pois():Array {
+            if (xml == null )
+                return null;
+            var pois:Array = [];
+            var counter:int = 0;
+            for each ( var feature:Feature in _features ) {
+              if (feature.isType("point")) {
+                pois.push(feature);
+              }
+            }
+            return pois;
+        }
     }
 
 }
index c862b3d65b6d7fd6b3a92e79c76912eebb9716e7..0ed126352b574ea8fb59740d0abbe2b3ca4f9b6b 100755 (executable)
             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:Array in tags ) {
-              node.setTag(tag[0],tag[1]);
+            for each ( var tag:Object in tags ) {
+              node.setTag(tag.k, tag.v);
             }
                        Connection.getConnectionInstance().registerPOI(node);
         }