[fusion-commits] r1464 - in trunk: MapGuide MapServer lib

svn_fusion at osgeo.org svn_fusion at osgeo.org
Thu Aug 21 16:42:11 EDT 2008


Author: madair
Date: 2008-08-21 16:42:10 -0400 (Thu, 21 Aug 2008)
New Revision: 1464

Modified:
   trunk/MapGuide/MapGuide.js
   trunk/MapServer/MapServer.js
   trunk/lib/Map.js
Log:
closes #108: fullExtents now sets the map to max extent; initial map load is done using initialExtents

Modified: trunk/MapGuide/MapGuide.js
===================================================================
--- trunk/MapGuide/MapGuide.js	2008-08-21 18:40:34 UTC (rev 1463)
+++ trunk/MapGuide/MapGuide.js	2008-08-21 20:42:10 UTC (rev 1464)
@@ -311,8 +311,8 @@
             if (this.bIsMapWidgetLayer) {
               this.mapWidget.addMap(this);
               this.mapWidget.oMapOL.setBaseLayer(this.oLayerOL);
-              this.mapWidget._oInitialExtents = null;
-              this.mapWidget.fullExtents();
+              var initialExtent = this.mapWidget.setInitialExtents();
+              this.mapWidget.setExtents(initialExtent);
               this.mapWidget.triggerEvent(Fusion.Event.MAP_LOADED);
             } else {
               this.triggerEvent(Fusion.Event.MAP_LOADED);
@@ -792,7 +792,7 @@
             'session': this.getSessionID(),
             'spatialfilter': options.geometry || '',
             'computed': options.computed || '',
-            'queryHiddenLayers': options.queryHiddenLayers || '',
+            'queryHiddenLayers': options.queryHiddenLayers || 'false',
             'maxfeatures': options.maxFeatures || 0, //zero means select all features
             'layers': options.layers || '',
             'variant': options.selectionType || this.selectionType
@@ -1204,7 +1204,7 @@
     },
     getLegendImageURL: function(fScale, layer) {
         var url = Fusion.getConfigurationItem('mapguide', 'mapAgentUrl');
-        url += "OPERATION=GETLEGENDIMAGE&SESSION=" + layer.oMap.getSessionID();
+        url += "?OPERATION=GETLEGENDIMAGE&SESSION=" + layer.oMap.getSessionID();
         url += "&VERSION=1.0.0&SCALE=" + fScale;
         url += "&LAYERDEFINITION=" + encodeURIComponent(layer.resourceId);
         url += "&THEMECATEGORY=" + this.categoryIndex;

Modified: trunk/MapServer/MapServer.js
===================================================================
--- trunk/MapServer/MapServer.js	2008-08-21 18:40:34 UTC (rev 1463)
+++ trunk/MapServer/MapServer.js	2008-08-21 20:42:10 UTC (rev 1464)
@@ -164,7 +164,7 @@
     loadMap: function(mapfile, options) {
         while (this.mapWidget.isBusy()) {
 	        this.mapWidget._removeWorker();
-		}
+        }
         this.bMapLoaded = false;
         //console.log('loadMap: ' + resourceId);
         /* don't do anything if the map is already loaded? */
@@ -290,8 +290,8 @@
               this.mapWidget.addMap(this);
               this.mapWidget.oMapOL.setBaseLayer(this.oLayerOL);
               this.mapWidget.oMapOL.units = this.oLayerOL.units;
-              this.mapWidget._oInitialExtents = null;
-              this.mapWidget.fullExtents();
+              var initialExtent = this.mapWidget.setInitialExtents();
+              this.mapWidget.setExtents(initialExtent);
               this.mapWidget.triggerEvent(Fusion.Event.MAP_LOADED);
             } else {
               this.triggerEvent(Fusion.Event.MAP_LOADED);

Modified: trunk/lib/Map.js
===================================================================
--- trunk/lib/Map.js	2008-08-21 18:40:34 UTC (rev 1463)
+++ trunk/lib/Map.js	2008-08-21 20:42:10 UTC (rev 1464)
@@ -59,7 +59,6 @@
     _fScale : -1,
     _nDpi : 96,
     _oCurrentExtents: null,
-    _oInitialExtents: null,
     maxExtent: new OpenLayers.Bounds(),
     _nWorkers: 0,
     oContextMenu: null,
@@ -503,8 +502,6 @@
         this._nHeight = d.height;
         if (this._oCurrentExtents) {
           this.setExtents(this._oCurrentExtents);
-        } else if (this._oInitialExtents) {
-          this.setExtents(this._oInitialExtents);
         }
         this.triggerEvent(Fusion.Event.MAP_RESIZED, this);
     },
@@ -518,7 +515,7 @@
       this.oMapOL.setCenter(this.oMapOL.getCenter(), this.oMapOL.getZoom(), false, true);
     },
     
-    setExtents : function(oExtents) {
+    setExtents: function(oExtents) {
         if (!oExtents) {
             Fusion.reportError(new Fusion.Error(Fusion.Error.WARNING, 
                                 OpenLayers.i18n('nullExtents')));
@@ -532,42 +529,55 @@
           this.aMaps[i].oLayerOL.params.ts = (new Date()).getTime();
         }
         this.oMapOL.zoomToExtent(oExtents);
+        this._oCurrentExtents = this.oMapOL.getExtent();
     },
 
-    fullExtents : function() {
-      //determine the initialExtents
-      if (!this._oInitialExtents) {
-        var bbox = Fusion.getQueryParam("extent");   //set as min x,y, max x,y
-        if (bbox) {
-          this._oInitialExtents = new OpenLayers.Bounds.fromArray(bbox.split(","));
-        } else if (this.mapGroup.initialView) {
-            var iv = this.mapGroup.getInitialView();
-            if (iv.x) {
-                this._oInitialExtents = this.getExtentFromPoint(iv.x, iv.y, iv.scale);                
-            } else if (iv.minX) {
-                this._oInitialExtents = new OpenLayers.Bounds(iv.minX, iv.minY, iv.maxX, iv.maxY);
-            }
-            if (!this._oInitialExtents.intersectsBounds(this.maxExtent)) {
-              Fusion.reportError("AppDef initial view is outside map maxExtent, resetting initialView to maxExtent");
-              this._oInitialExtents = this.maxExtent;
-            }
-        } else {
-          var viewSize = this.oMapOL.getSize();
-          var oExtents = this.oMapOL.getMaxExtent();
-          var center = oExtents.getCenterLonLat();
-          var initRes = Math.max( oExtents.getWidth()  / viewSize.w,
-                                  oExtents.getHeight() / viewSize.h);
-          var w_deg = viewSize.w * initRes/2;
-          var h_deg = viewSize.h * initRes/2;
-          this._oInitialExtents = new OpenLayers.Bounds(center.lon - w_deg,
-                                             center.lat - h_deg,
-                                             center.lon + w_deg,
-                                             center.lat + h_deg);
-        }
+    /**
+     * determine the initialExtents of the map from (in order of precedence):
+     * 1. a URL query parameter called 'extent'
+     * 2. an <InitialView> specified in the MapGroup in AppDef
+     * 3. the maxExtent as specified by the LoadMap call (default)
+     */
+    setInitialExtents: function() {
+      var initialExtents;
+      var bbox = Fusion.getQueryParam("extent");   //set as min x,y, max x,y
+      if (bbox) {
+        initialExtents = new OpenLayers.Bounds.fromArray(bbox.split(","));
+      } else if (this.mapGroup.initialView) {
+          var iv = this.mapGroup.getInitialView();
+          if (iv.x) {
+              initialExtents = this.getExtentFromPoint(iv.x, iv.y, iv.scale);                
+          } else if (iv.minX) {
+              initialExtents = new OpenLayers.Bounds(iv.minX, iv.minY, iv.maxX, iv.maxY);
+          }
+          if (!initialExtents.intersectsBounds(this.maxExtent)) {
+            Fusion.reportError("AppDef initial view is outside map maxExtent, resetting initialView to maxExtent");
+            initialExtents = this.maxExtent;
+          }
+      } else {
+        var viewSize = this.oMapOL.getSize();
+        var oExtents = this.oMapOL.getMaxExtent();
+        var center = oExtents.getCenterLonLat();
+        var initRes = Math.max( oExtents.getWidth()  / viewSize.w,
+                                oExtents.getHeight() / viewSize.h);
+        var w_deg = viewSize.w * initRes/2;
+        var h_deg = viewSize.h * initRes/2;
+        initialExtents = new OpenLayers.Bounds(center.lon - w_deg,
+                                           center.lat - h_deg,
+                                           center.lon + w_deg,
+                                           center.lat + h_deg);
       }
-      this.setExtents(this._oInitialExtents); 
+      return initialExtents; 
     },
 
+    /**
+     * sets the extent of the map to the max as returned by loadMap
+     */
+    fullExtents: function() {
+      var extents = this.maxExtent;
+      this.setExtents(extents); 
+    },
+
     isMapLoaded: function() {
         return (this._oCurrentExtents) ? true : false;
     },
@@ -703,13 +713,22 @@
      *
      */
     setViewOptions: function(data) {
+      this.setWidgetParam('Units', data);
+    },
+    
+  /**
+     *
+     * initializes all widgets with a parameter and value at runtime
+     *
+     */
+    setWidgetParam: function(param, data) {
       for (var i=0; i<Fusion.applicationDefinition.widgetSets.length; ++i) {
         var widgetSet = Fusion.applicationDefinition.widgetSets[i];
         for (var j=0; j<widgetSet.widgetInstances.length; ++j) {
           var widget = widgetSet.widgetInstances[j];
           for (var k=0; k<widget.paramRegister.length; ++k) {
-            if (widget.paramRegister[k] == 'Units') {
-              widget.setParameter('Units', data);
+            if (widget.paramRegister[k] == param) {
+              widget.setParameter(param, data);
             }
           }
         }
@@ -751,14 +770,6 @@
     },
 
     /**
-     *
-     * returns initial extents
-    */
-    getInitialExtents : function(){
-        return this._oInitialExtents;
-    },
-
-    /**
      * Function: getExtentFromPoint
      *
      * returns the Extent of the map given a center point and a scale (optional)



More information about the fusion-commits mailing list