[fusion-commits] r2441 - trunk/widgets
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Wed Oct 26 02:43:19 EDT 2011
Author: liuar
Date: 2011-10-25 23:43:19 -0700 (Tue, 25 Oct 2011)
New Revision: 2441
Modified:
trunk/widgets/Legend.js
Log:
Fix ticket #476 Legend of Raster Layer is not displayed in legend panel
This is a regression from Fusion2.2, I port my patch from Ticket #306 to trunk to fix this defect.
Modified: trunk/widgets/Legend.js
===================================================================
--- trunk/widgets/Legend.js 2011-10-25 01:02:03 UTC (rev 2440)
+++ trunk/widgets/Legend.js 2011-10-26 06:43:19 UTC (rev 2441)
@@ -564,8 +564,8 @@
/* remember the range we are now representing for the next update */
layer.legend.currentRange = range;
- /* if layer is in range and has at least one style */
- if (range != null && range.styles && range.styles.length > 0) {
+ /* if layer is in range */
+ if (range != null && range.styles) {
/* if it has more than one style, we represent it as a folder
* with classes as items in it
*/
@@ -602,10 +602,10 @@
layer.legend.treeItem.add(item);
}
}
- /* if there is only one style, we represent it as a tree item */
+ /* if there is only one style or no style, we represent it as a tree item */
} else {
var style = range.styles[0];
- if (!style.legendLabel) {
+ if (style && !style.legendLabel) {
style.legendLabel = layer.legendLabel;
}
if (!layer.legend.treeItem) {
@@ -721,7 +721,14 @@
createTreeItem: function(layer, style, scale, checkbox) {
var opt = {};
opt.statusIsDefault = layer.statusDefault;
- opt.label = style.legendLabel == '' ? ' ' : style.legendLabel;
+
+ //set the label
+ if (style && style.legendLabel) {
+ opt.label = style.legendLabel == '' ? ' ' : style.legendLabel;
+ } else {
+ opt.label = layer.legendLabel == '' ? ' ' : layer.legendLabel;
+ }
+
if (layer.metadata) {
opt.selectable = !layer.metadata.jxUnselectable || (layer.metadata.jxUnselectable && layer.metadata.jxUnselectable != 'true');
} else {
@@ -732,22 +739,21 @@
opt.image = this.imgDisabledLayerIcon;
opt.enabled = false;
} else {
- var defaultIcon = this.imgDisabledLayerIcon;
- if (layer.layerTypes[0] == 4) {
- if (style.staticIcon == Fusion.Constant.LAYER_DWF_TYPE) {
- defaultIcon = this.imgLayerDWFIcon;
- } else {
- defaultIcon = this.imgLayerRasterIcon;
- }
- }
- if (style.iconOpt && style.iconOpt.url) {
- //if (style.iconOpt.url.indexOf("data:image") >= 0)
- // console.log("Fetching pre-cached icon");
+ if(style.iconOpt && style.iconOpt.url){
opt.image = style.iconOpt.url;
- } else {
+ }else{
opt.image = layer.oMap.getLegendImageURL(scale, layer, style);
}
}
+ // MapGuide DWF and Raster layer
+ // MapGuide Raster and DWF layer
+ if(layer.layerTypes[0] == 4){
+ opt.image = this.imgLayerRasterIcon;
+ opt.enabled = true;
+ } else if(layer.layerTypes[0] == 5){
+ opt.image = this.imgLayerDWFIcon;
+ opt.enabled = true;
+ }
var item;
if (checkbox) {
More information about the fusion-commits
mailing list