[fusion-commits] r1225 - in trunk: MapGuide lib widgets
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Mon Mar 10 09:30:25 EDT 2008
Author: pagameba
Date: 2008-03-10 09:30:23 -0400 (Mon, 10 Mar 2008)
New Revision: 1225
Modified:
trunk/MapGuide/MapGuide.js
trunk/lib/ApplicationDefinition.js
trunk/widgets/Legend.js
Log:
Re #20. Initial rework of Links and LayerEvents support, needs testing.
Modified: trunk/MapGuide/MapGuide.js
===================================================================
--- trunk/MapGuide/MapGuide.js 2008-03-10 13:29:17 UTC (rev 1224)
+++ trunk/MapGuide/MapGuide.js 2008-03-10 13:30:23 UTC (rev 1225)
@@ -876,6 +876,28 @@
var params = {};
params.parameters = 'session='+this.getSessionID();
Fusion.ajaxRequest(s, params);
+ },
+ getGroupInfoUrl: function(groupName) {
+ if (this.mapInfo) {
+ var groups = this.mapInfo.links.groups;
+ for (var i=0; i<groups.length; i++) {
+ if (groups[i].name == groupName) {
+ return groups[i].url;
+ }
+ }
+ }
+ return null;
+ },
+ getLayerInfoUrl: function(layerName) {
+ if (this.mapInfo) {
+ var layers = this.mapInfo.links.layers;
+ for (var i=0; i<layers.length; i++) {
+ if (layers[i].name == layerName) {
+ return layers[i].url;
+ }
+ }
+ }
+ return null;
}
};
Modified: trunk/lib/ApplicationDefinition.js
===================================================================
--- trunk/lib/ApplicationDefinition.js 2008-03-10 13:29:17 UTC (rev 1224)
+++ trunk/lib/ApplicationDefinition.js 2008-03-10 13:30:23 UTC (rev 1225)
@@ -418,61 +418,59 @@
if (jsonNode.Map instanceof Array) {
for (var i=0; i<jsonNode.Map.length; i++) {
var map = new Fusion.Lib.ApplicationDefinition.Map(jsonNode.Map[i]);
- this.maps.push(map);
- }
- } else {
- //TODO: do we need a warning that there are no layers in this map?
- }
- this.links = {groups:[], layers:[]};
- this.layerEvents = {};
- if (jsonNode.Extension) {
- var extension = jsonNode.Extension[0];
- if (extension.Links) {
- /* process Groups */
- if (extension.Links[0].Group instanceof Array) {
- for (var j=0; j<extension.Links[0].Group.length; j++) {
- var group = extension.Links[0].Group[j];
- this.links.groups.push({name:group.Name,url:group.Url});
- }
- }
- if (extension.Links[0].Layer instanceof Array) {
- for (var j=0; j<extension.Links[0].Layer.length; j++) {
- var layer = extension.Links[0].Layer[j];
- this.links.layers.push({name:layer.Name,url:layer.Url});
- }
- }
- }
- /* process layer events */
- //TODO: Should this be called MapEvents?
- if (extension.LayerEvents) {
- if (extension.LayerEvents[0].Layer instanceof Array) {
- for (var j=0; j<extension.LayerEvents[0].Layer.length; j++) {
- var layer = extension.LayerEvents[0].Layer[j];
- var layerObj = {};
- layerObj.name = layer.Name[0];
- layerObj.onEnable = [];
- layerObj.onDisable = [];
-
- if (layer.OnEnable instanceof Array) {
- for (var k=0; k<layer.OnEnable[0].Layer.length; k++) {
- var kLayer = layer.OnEnable[0].Layer[k];
- layerObj.onEnable.push({name:kLayer.Name[0], enable: kLayer.Enable[0] == 'true' ? true : false});
+ var links = {groups:[], layers:[]};
+ var layerEvents = {};
+ if (jsonNode.Extension) {
+ var extension = jsonNode.Extension[0];
+ if (extension.Links) {
+ /* process Groups */
+ if (extension.Links[0].Group instanceof Array) {
+ for (var j=0; j<extension.Links[0].Group.length; j++) {
+ var group = extension.Links[0].Group[j];
+ links.groups.push({name:group.Name,url:group.Url});
}
}
- if (layer.OnDisable instanceof Array) {
- for (var k=0; k<layer.OnDisable[0].Layer.length; k++) {
- var kLayer = layer.OnDisable[0].Layer[k];
- layerObj.onDisable.push({name:kLayer.Name[0], enable: kLayer.Enable[0] == 'true' ? true : false});
+ if (extension.Links[0].Layer instanceof Array) {
+ for (var j=0; j<extension.Links[0].Layer.length; j++) {
+ var layer = extension.Links[0].Layer[j];
+ links.layers.push({name:layer.Name,url:layer.Url});
}
}
- this.layerEvents[layerObj.name] = layerObj;
}
+ /* process layer events */
+ //TODO: Should this be called MapEvents?
+ if (extension.LayerEvents) {
+ if (extension.LayerEvents[0].Layer instanceof Array) {
+ for (var j=0; j<extension.LayerEvents[0].Layer.length; j++) {
+ var layer = extension.LayerEvents[0].Layer[j];
+ var layerObj = {};
+ layerObj.name = layer.Name[0];
+ layerObj.onEnable = [];
+ layerObj.onDisable = [];
+
+ if (layer.OnEnable instanceof Array) {
+ for (var k=0; k<layer.OnEnable[0].Layer.length; k++) {
+ var kLayer = layer.OnEnable[0].Layer[k];
+ layerObj.onEnable.push({name:kLayer.Name[0], enable: kLayer.Enable[0] == 'true' ? true : false});
+ }
+ }
+ if (layer.OnDisable instanceof Array) {
+ for (var k=0; k<layer.OnDisable[0].Layer.length; k++) {
+ var kLayer = layer.OnDisable[0].Layer[k];
+ layerObj.onDisable.push({name:kLayer.Name[0], enable: kLayer.Enable[0] == 'true' ? true : false});
+ }
+ }
+ layerEvents[layerObj.name] = layerObj;
+ }
+ }
+ }
}
+ map.mapInfo = {links: links, layerEvents: layerEvents};
+ this.maps.push(map);
}
} else {
- this.extension = {};
+ //TODO: do we need a warning that there are no layers in this map?
}
-
},
getInitialView: function() {
Modified: trunk/widgets/Legend.js
===================================================================
--- trunk/widgets/Legend.js 2008-03-10 13:29:17 UTC (rev 1224)
+++ trunk/widgets/Legend.js 2008-03-10 13:30:23 UTC (rev 1225)
@@ -210,7 +210,6 @@
if (this.showRootFolder) {
this.oRoot.setName(map.getMapTitle());
}
- this.oMapInfo = map.oMapInfo;
var startGroup = map.layerRoot;
if (!this.showMapFolder) {
startGroup = map.layerRoot.groups[0];
@@ -247,7 +246,7 @@
group.legend.checkBox.checked = group.visible?true:false;
Event.observe(group.legend.checkBox, 'click', this.stateChanged.bind(this, group));
Event.observe(group.legend.treeItem.domObj, 'mouseover', this.setFolder.bind(this));
- var groupInfo = this.getGroupInfoUrl(group.groupName);
+ var groupInfo = group.oMap.getGroupInfoUrl(group.groupName);
if (groupInfo) {
var a = document.createElement('a');
a.href = groupInfo;
@@ -424,7 +423,7 @@
opt.imgTreeFolder = this.imgLayerThemeIcon;
var folder = new Jx.TreeFolder(opt);
folder.domObj.insertBefore(layer.legend.checkBox, folder.domObj.childNodes[1]);
- var layerInfo = this.getLayerInfoUrl(layer.layerName);
+ var layerInfo = layer.oMap.getLayerInfoUrl(layer.layerName);
if (layerInfo) {
var a = document.createElement('a');
a.href = layerInfo;
@@ -500,27 +499,5 @@
obj.hide();
}
}
- },
- getGroupInfoUrl: function(groupName) {
- if (this.oMapInfo) {
- var groups = this.oMapInfo.links.groups;
- for (var i=0; i<groups.length; i++) {
- if (groups[i].name == groupName) {
- return groups[i].url;
- }
- }
- }
- return null;
- },
- getLayerInfoUrl: function(layerName) {
- if (this.oMapInfo) {
- var layers = this.oMapInfo.links.layers;
- for (var i=0; i<layers.length; i++) {
- if (layers[i].name == layerName) {
- return layers[i].url;
- }
- }
- }
- return null;
}
};
More information about the fusion-commits
mailing list