[fusion-commits] r2539 - trunk/widgets

svn_fusion at osgeo.org svn_fusion at osgeo.org
Tue Jun 26 13:45:49 PDT 2012


Author: madair
Date: 2012-06-26 13:45:48 -0700 (Tue, 26 Jun 2012)
New Revision: 2539

Modified:
   trunk/widgets/Legend.js
Log:
get legend icon from sprite if available when layer comes into range

Modified: trunk/widgets/Legend.js
===================================================================
--- trunk/widgets/Legend.js	2012-05-30 08:52:09 UTC (rev 2538)
+++ trunk/widgets/Legend.js	2012-06-26 20:45:48 UTC (rev 2539)
@@ -623,7 +623,16 @@
                     layer.parentGroup.legend.treeItem.add(layer.legend.treeItem);
                 } else {
                     if (range.styles.length > 0) {
-                        var url = layer.oMap.getLegendImageURL(fScale, layer, range.styles[0]);
+                        var url;
+                        if(style.iconOpt && style.iconOpt.url){
+                            url = style.iconOpt.url;
+                            var img = layer.legend.treeItem.elements.get('jxTreeIcon');
+                            var iconX = -1 * style.iconX;
+                            var iconY = -1 * style.iconY;
+                            img.style.backgroundPosition = iconX + 'px ' + iconY + 'px';
+                        }else{
+                            url = layer.oMap.getLegendImageURL(scale, layer, style);
+                        }
                         layer.legend.treeItem.setImage(url);
                         layer.legend.treeItem.enable(true);
                     } else {
@@ -760,6 +769,7 @@
         }
         // MapGuide DWF and Raster layer
          // MapGuide Raster and DWF layer
+
         if(layer.layerTypes[0] == 4){
             opt.image = this.imgLayerRasterIcon;
             opt.enabled = true;
@@ -768,6 +778,7 @@
             opt.enabled = true;
         }
 
+
         var item;
         if (!layer.isBaseMapLayer&&checkbox) {
             // opt.contextMenu = this.getContextMenu();
@@ -814,8 +825,8 @@
             }
             iconX = -1 * (style.iconX + this.iconWidth);
             iconY = -1 * (style.iconY + this.iconHeight);
+            img.style.backgroundPosition = iconX + 'px ' + iconY + 'px';
         }
-        img.style.backgroundPosition = iconX + 'px ' + iconY + 'px';
         
         return item;
     },
@@ -1004,4 +1015,4 @@
             this.groupInfoIcon.set('src', icon);
         }
     }
-});
\ No newline at end of file
+});



More information about the fusion-commits mailing list