[fusion-commits] r1734 - trunk/lib

svn_fusion at osgeo.org svn_fusion at osgeo.org
Wed Jan 14 10:23:02 EST 2009


Author: madair
Date: 2009-01-14 10:23:01 -0500 (Wed, 14 Jan 2009)
New Revision: 1734

Modified:
   trunk/lib/ApplicationDefinition.js
Log:
re #34: support for URL mapid param to override mapid specified in AppDef

Modified: trunk/lib/ApplicationDefinition.js
===================================================================
--- trunk/lib/ApplicationDefinition.js	2009-01-08 18:35:06 UTC (rev 1733)
+++ trunk/lib/ApplicationDefinition.js	2009-01-14 15:23:01 UTC (rev 1734)
@@ -89,7 +89,7 @@
         this.applicationDefinition =  Fusion.getApplicationDefinitionURL();
         
         this.widgetSets = [];
-        this.mapGroups = [];
+        this.mapGroups = {};
         this.searchDefinitions = [];
         this.searchCategories = [];
         this.parse();
@@ -184,7 +184,7 @@
             if (mapSet.MapGroup instanceof Array) {
                 for (var i=0; i<mapSet.MapGroup.length; i++) {
                     var mapGroup = new Fusion.Lib.ApplicationDefinition.MapGroup(mapSet.MapGroup[i]);
-                    this.mapGroups.push(mapGroup);
+                    this.mapGroups[mapGroup.mapId] = mapGroup;
                 }
             }
         } else {
@@ -320,14 +320,7 @@
      * Returns: {Object} a MapGroup appdef or null if not found.
      */
      getMapGroup : function(mapGroupId) {
-         var mapGroup = null;
-         for (var i=0; i<this.mapGroups.length; ++i) {
-           if (this.mapGroups[i].mapId == mapGroupId) {
-             mapGroup = this.mapGroups[i];
-             break;
-           }
-         }
-         return mapGroup;
+         return this.mapGroups[mapGroupId];
      },
      
      /**
@@ -510,7 +503,7 @@
               this.layerOptions[key] = false;
             }
             if (key == 'maxExtent' || key == 'minExtent') {
-              this.layerOptions[key] = OpenLayers.Bounds.fromString(this.layerOptions[key])
+              this.layerOptions[key] = OpenLayers.Bounds.fromString(this.layerOptions[key]);
             }
           }
         }
@@ -569,12 +562,6 @@
             }
         }
         
-        //allow over-ride of mapId via URL parameter
-        var paramMapId = Fusion.getQueryParam('mapid');
-        if (paramMapId.length>0) {
-          this.mapId = paramMapId;
-        }
-        
         /* process widgets */
         if (jsonNode.Widget) {
             for (var i=0; i<jsonNode.Widget.length; i++) {
@@ -631,17 +618,23 @@
      */
     create: function(appDef) {
 
-        //find the map group for the map requested
+        //allow over-ride of mapId via URL parameter
         var mapGroup = null;
-        if (this.mapId) {
-            for (var i=0; i<appDef.mapGroups.length; ++i) {
-              if (this.mapId == appDef.mapGroups[i].mapId) {
-                mapGroup = appDef.mapGroups[i];
-                break;
-              }
-            }
+        var paramMapId = Fusion.getQueryParam('mapid');
+        if (paramMapId.length>0) {
+          mapGroup = appDef.getMapGroup(paramMapId);
+          if (mapGroup) {
+            this.mapId = paramMapId;
+          } else {
+            Fusion.reportError(new Fusion.Error(Fusion.Error.WARNING, 
+              "can't find MapGroup: " + paramMapId + ' - reverting to default map'));
+          }
         }
         
+        if (!mapGroup) {
+          mapGroup = appDef.getMapGroup(this.mapId);
+        }
+        
         //create the Map widget for this WidgetSet
         this.mapWidget = new Fusion.Widget.Map(this.mapWidgetTag,mapGroup,this);
         this.mapWidget.setMenu();
@@ -906,7 +899,6 @@
                 break;
             case 'Separator':   
                 break;
-                  break;
         }
     },
       



More information about the fusion-commits mailing list