[fusion-commits] r1362 - trunk/widgets
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Mon Apr 7 14:32:51 EDT 2008
Author: zjames
Date: 2008-04-07 14:32:50 -0400 (Mon, 07 Apr 2008)
New Revision: 1362
Modified:
trunk/widgets/MapMenu.js
Log:
Re #47, improved enumeration vs mapgroup interaction
Modified: trunk/widgets/MapMenu.js
===================================================================
--- trunk/widgets/MapMenu.js 2008-04-07 15:49:45 UTC (rev 1361)
+++ trunk/widgets/MapMenu.js 2008-04-07 18:32:50 UTC (rev 1362)
@@ -36,6 +36,7 @@
{
domObj: null,
oMenu: null,
+ mapGroupData: null,
sRootFolder: '',
aMenus : null,
initialize : function(widgetTag)
@@ -46,15 +47,26 @@
this.enable();
var json = widgetTag.extension;
+
+ //If no folder is specified for enumeration, build a menu
+ //from the mapgroup alone. Folders are only supported with MapGuide.
+ //Otherwise, create a hash of mapgroup resourceId to mapGroup data
+ //to be used to assign mapgroup extensions to enumerated maps.
+
var mapGroups = Fusion.applicationDefinition.mapGroups;
+ this.mapGroupData = {};
for (var i=0; i<mapGroups.length; i++) {
var mapGroup = mapGroups[i];
- var opt = {};
- opt.label = mapGroup.mapId;
- var data = mapGroup;
- var action = new Jx.Action(this.switchMap.bind(this, data));
- var menuItem = new Jx.MenuItem(action,opt);
- this.oMenu.add(menuItem);
+ if (json.Folder) {
+ this.mapGroupData[mapGroup.maps[0].resourceId] = mapGroup;
+ } else {
+ var opt = {};
+ opt.label = mapGroup.mapId;
+ var data = mapGroup;
+ var action = new Jx.Action(this.switchMap.bind(this, data));
+ var menuItem = new Jx.MenuItem(action,opt);
+ this.oMenu.add(menuItem);
+ }
}
//get the mapdefinitions as xml if there is a folder specified
@@ -82,21 +94,32 @@
var sId = mapNode.getNodeText('ResourceId');
var sPath = sId.replace(this.sRootFolder, '');
- sPath = sPath.slice(0, sPath.lastIndexOf('/'));
- this.createFolders(sPath);
+ if (sPath.lastIndexOf('/') > -1) {
+ sPath = sPath.slice(0, sPath.lastIndexOf('/'));
+ this.createFolders(sPath);
+ } else {
+ sPath = '';
+ }
var opt = {};
opt.label = mapNode.getNodeText('Name');
+
+ // check for mapgroup data and if there is none,
// create a maptag that will be passed to the map
- // widget constructor
- var data = {maps:[{'resourceId':mapNode.getNodeText('ResourceId'),
+ // widget constructor
+ var data = null;
+ if (this.mapGroupData[mapNode.getNodeText('ResourceId')]) {
+ data = this.mapGroupData[mapNode.getNodeText('ResourceId')];
+ } else {
+ data = {maps:[{'resourceId':mapNode.getNodeText('ResourceId'),
'singleTile':true,
'type': this.arch,
'extension':{'ResourceId': [mapNode.getNodeText('ResourceId')]}
}]};
- //set up needed accessor
- data.getInitialView = function() {
- return this.initialView;
- };
+ //set up needed accessor
+ data.getInitialView = function() {
+ return this.initialView;
+ };
+ }
var action = new Jx.Action(this.switchMap.bind(this, data));
var menuItem = new Jx.MenuItem(action,opt);
More information about the fusion-commits
mailing list