[fusion-commits] r1936 - in trunk: layers layers/MapServer widgets
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Thu Oct 8 11:58:03 EDT 2009
Author: pagameba
Date: 2009-10-08 11:58:02 -0400 (Thu, 08 Oct 2009)
New Revision: 1936
Modified:
trunk/layers/Layers.js
trunk/layers/MapServer/MapServer.js
trunk/widgets/Legend.js
Log:
Re #131, implement client side behaviour for detecting a legend icon image strip and using it if available.
Modified: trunk/layers/Layers.js
===================================================================
--- trunk/layers/Layers.js 2009-10-07 20:33:03 UTC (rev 1935)
+++ trunk/layers/Layers.js 2009-10-08 15:58:02 UTC (rev 1936)
@@ -548,7 +548,7 @@
Fusion.Layers.ScaleRange = OpenLayers.Class({
styles: null,
- initialize: function(o, layerType) {
+ initialize: function(o, layerType, iconOpt) {
this.minScale = o.minScale;
this.maxScale = o.maxScale;
if (this.maxScale == 'infinity' || this.maxScale == 'auto') {
@@ -556,13 +556,13 @@
}
this.styles = [];
if (!o.styles) {
- var styleItem = new Fusion.Layers.StyleItem({legendLabel:'DWF'}, layerType);
+ var styleItem = new Fusion.Layers.StyleItem({legendLabel:'DWF'}, layerType, iconOpt);
this.styles.push(styleItem);
return;
}
var staticIcon = o.styles.length>1 ? false : layerType;
for (var i=0; i<o.styles.length; i++) {
- var styleItem = new Fusion.Layers.StyleItem(o.styles[i], staticIcon);
+ var styleItem = new Fusion.Layers.StyleItem(o.styles[i], staticIcon, iconOpt);
this.styles.push(styleItem);
}
},
@@ -580,7 +580,10 @@
Fusion.Layers.StyleItem = OpenLayers.Class({
clientAgent: 'Fusion Viewer',
- initialize: function(o, staticIcon) {
+ initialize: function(o, staticIcon, iconOpt) {
+ this.iconOpt = iconOpt;
+ this.iconX = o.icon_x || 0;
+ this.iconY = o.icon_y || 0;
this.legendLabel = o.legendLabel;
this.filter = o.filter;
this.geometryType = o.geometryType;
Modified: trunk/layers/MapServer/MapServer.js
===================================================================
--- trunk/layers/MapServer/MapServer.js 2009-10-07 20:33:03 UTC (rev 1935)
+++ trunk/layers/MapServer/MapServer.js 2009-10-08 15:58:02 UTC (rev 1936)
@@ -326,24 +326,24 @@
Fusion.ajaxRequest(loadmapScript, options);
},
- scaleRangesLoaded: function(userFunc, r)
- {
- if (r.status == 200)
- {
+ scaleRangesLoaded: function(userFunc, r) {
+ if (r.status == 200) {
var o;
eval('o='+r.responseText);
- if (o.layers && o.layers.length > 0)
- {
- for (var i=0; i<o.layers.length; i++)
- {
+
+ if (o.layers && o.layers.length > 0) {
+ var iconOpt = {
+ url: o.icons_url || null,
+ width: o.icons_width || 16,
+ height: o.icons_height || 16,
+ };
+ for (var i=0; i<o.layers.length; i++) {
var oLayer = this.getLayerById(o.layers[i].uniqueId);
- if (oLayer)
- {
+ if (oLayer) {
oLayer.scaleRanges = [];
- for (var j=0; j<o.layers[i].scaleRanges.length; j++)
- {
+ for (var j=0; j<o.layers[i].scaleRanges.length; j++) {
var scaleRange = new Fusion.Layers.ScaleRange(o.layers[i].scaleRanges[j],
- oLayer.layerType);
+ oLayer.layerType, iconOpt);
oLayer.scaleRanges.push(scaleRange);
}
}
Modified: trunk/widgets/Legend.js
===================================================================
--- trunk/widgets/Legend.js 2009-10-07 20:33:03 UTC (rev 1935)
+++ trunk/widgets/Legend.js 2009-10-08 15:58:02 UTC (rev 1936)
@@ -680,13 +680,27 @@
defaultIcon = this.imgLayerRasterIcon;
}
}
- opt.image = layer.oMap.getLegendImageURL(scale, layer, style, defaultIcon);
+ if (style.iconOpt && style.iconOpt.url) {
+ opt.image = style.iconOpt.url;
+ } else {
+ opt.image = layer.oMap.getLegendImageURL(scale, layer, style, defaultIcon);
+ }
}
opt.contextMenu = this.getContextMenu();
var item = new Jx.TreeItem(opt);
-
-
+ if (style && style.iconX >= 0 && style.iconY >= 0) {
+ item.domImg;
+ item.domImg.style.backgroundImage = 'url('+opt.image+')';
+ item.domImg.src = Jx.aPixel.src;
+ item.domImg.style.backgroundPosition = (-1*style.iconX) + 'px ' + (-1*style.iconY) + 'px';
+ if (style.iconOpt.width) {
+ item.domImg.style.width = style.iconOpt.width + 'px';
+ }
+ if (style.iconOpt.height) {
+ item.domImg.style.height = style.iconOpt.height + 'px';
+ }
+ }
if (bCheckBox) {
//item.domObj.insertBefore(layer.legend.checkBox, item.domObj.childNodes[1]);
More information about the fusion-commits
mailing list