[fusion-commits] r2380 - in trunk: layers/MapServer widgets
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Thu May 12 15:54:21 EDT 2011
Author: madair
Date: 2011-05-12 12:54:21 -0700 (Thu, 12 May 2011)
New Revision: 2380
Modified:
trunk/layers/MapServer/MapServer.js
trunk/widgets/MapMetadata.js
Log:
re #447: adding support for Layer metadata
Modified: trunk/layers/MapServer/MapServer.js
===================================================================
--- trunk/layers/MapServer/MapServer.js 2011-05-11 18:15:37 UTC (rev 2379)
+++ trunk/layers/MapServer/MapServer.js 2011-05-12 19:54:21 UTC (rev 2380)
@@ -272,7 +272,6 @@
this.layerRoot.displayInLegend = true;
this.layerRoot.expandInLegend = true;
- o.groups.sort(function(a,b) {return a.depth-b.depth} );
this.parseMapLayersAndGroups(o);
var minScale = 1.0e10;
@@ -479,6 +478,9 @@
},
parseMapLayersAndGroups: function(o) {
+ //sort the groups so that root folders are created before subfolders
+ o.groups.sort(function(a,b) {return a.depth-b.depth} );
+
for (var i=0; i<o.groups.length; i++) {
var group = new Fusion.Layers.Group(o.groups[i], this);
var parent;
@@ -833,12 +835,33 @@
Fusion.ajaxRequest(s, params);
},
- getMetadata: function(key) {
+ getMetadata: function(key, layerName) {
+ if (layerName) {
+ var layer = this.getLayerByName(layerName);
+ if (layer.metadata && typeof layer.metadata[key] != 'undefined') {
+ return layer.metadata[key];
+ } else {
+ return '';
+ }
+
+ } else {
if (this.metadata && typeof this.metadata[key] != 'undefined') {
return this.metadata[key];
} else {
- return '';
+ //TODO: a better way to create the layer metadata string?
+ var metadataString = ''
+ var join = "";
+ for (var i=0; i<this.aLayers.length; i++) {
+ if (this.aLayers[i].metadata &&
+ typeof this.aLayers[i].metadata[key] != 'undefined' &&
+ this.aLayers[i].metadata[key].length>0 ) {
+ metadataString += join + this.aLayers[i].legendLabel + ":" + this.aLayers[i].metadata[key] ;
+ join = " - ";
+ }
+ }
+ return metadataString;
}
+ }
},
getGroupInfoUrl: function(groupName) {
Modified: trunk/widgets/MapMetadata.js
===================================================================
--- trunk/widgets/MapMetadata.js 2011-05-11 18:15:37 UTC (rev 2379)
+++ trunk/widgets/MapMetadata.js 2011-05-12 19:54:21 UTC (rev 2380)
@@ -33,6 +33,7 @@
Fusion.Widget.MapMetadata = OpenLayers.Class(Fusion.Widget, {
content: 'text',
+ layerName: null,
/*
* Constructor: MapMetadata
@@ -52,6 +53,9 @@
if (json.Content) {
this.content = json.Content[0];
}
+ if (json.LayerName) {
+ this.layerName = json.LayerName[0];
+ }
this.getMap().registerForEvent(Fusion.Event.MAP_LOADED, OpenLayers.Function.bind(this.showMetadata, this));
},
@@ -63,7 +67,7 @@
*/
showMetadata: function() {
var metadataLayer = this.getMapLayer();
- var metadata = metadataLayer.getMetadata(this.metadataId);
+ var metadata = metadataLayer.getMetadata(this.metadataId, this.layerName);
if (metadata) {
//this.domObj.appendChild(metadata);
if (this.content == 'markup') {
More information about the fusion-commits
mailing list