Ensure that all POIs have an icon, and that there's no opportunity to dnd before...
authorAndy Allan <gravitystorm@gmail.com>
Thu, 21 Oct 2010 14:05:26 +0000 (14:05 +0000)
committerAndy Allan <gravitystorm@gmail.com>
Thu, 21 Oct 2010 14:05:26 +0000 (14:05 +0000)
TODO.txt
embedded/missing_icon.png [new file with mode: 0644]
net/systemeD/potlatch2/mapfeatures/Feature.as

index 3127b61..c2a47bb 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -20,7 +20,6 @@ Potlatch 2: main outstanding issues
 == Tag editing ==
 
 * initialiseEditors is quite slow (typically 150ms)
-* Bug where the wrong feature is used, when an item that is dragged from the list when an POI has no icon.
 * Can't use + for second tag
 * Tag panel jumps up and down when number spinner is used on bike parking
 * New relation panel jumps up and down, but I haven't seen it on editing existing relations
diff --git a/embedded/missing_icon.png b/embedded/missing_icon.png
new file mode 100644 (file)
index 0000000..faf2d0e
Binary files /dev/null and b/embedded/missing_icon.png differ
index 69a1dfb..0ad7135 100644 (file)
@@ -4,6 +4,8 @@ package net.systemeD.potlatch2.mapfeatures {
     import flash.events.Event;
     import flash.net.*;
     import flash.utils.ByteArray;
+    import mx.core.BitmapAsset;
+    import mx.graphics.codec.PNGEncoder;
     
     import net.systemeD.halcyon.connection.Entity;
     import net.systemeD.potlatch2.utils.CachedDataLoader;
@@ -16,6 +18,11 @@ package net.systemeD.potlatch2.mapfeatures {
                private var _withins:Array;
         private var _editors:Array;
 
+        [Embed(source="../../../../embedded/missing_icon.png")]
+        [Bindable]
+        public var missingIconCls:Class;
+
+
         public function Feature(mapFeatures:MapFeatures, _xml:XML) {
             this.mapFeatures = mapFeatures;
             this._xml = _xml;
@@ -95,14 +102,19 @@ package net.systemeD.potlatch2.mapfeatures {
         public function get image():ByteArray {
             var icon:XMLList = _xml.icon;
             var imageURL:String = null;
+            var img:ByteArray;
 
             if ( icon.length() > 0 && icon[0].hasOwnProperty("@image") )
                 imageURL = icon[0].@image;
-            
+
             if ( imageURL != null ) {
-                return CachedDataLoader.loadData(imageURL, imageLoaded);
+                img = CachedDataLoader.loadData(imageURL, imageLoaded);
             }
-            return null;
+            if (img) {
+              return img;
+            }
+            var bitmap:BitmapAsset = new missingIconCls() as BitmapAsset;
+            return new PNGEncoder().encode(bitmap.bitmapData);
         }
         
         private function imageLoaded(url:String, data:ByteArray):void {