[OpenLayers-Commits] r5154 - sandbox/madair/lib/OpenLayers/Layer

commits at openlayers.org commits at openlayers.org
Thu Nov 8 16:18:34 EST 2007


Author: madair
Date: 2007-11-08 16:18:31 -0500 (Thu, 08 Nov 2007)
New Revision: 5154

Modified:
   sandbox/madair/lib/OpenLayers/Layer/MapGuide.js
Log:
implementation of GETDYNAMICMAPOVERLAY image for non-tiled, non-base layers

Modified: sandbox/madair/lib/OpenLayers/Layer/MapGuide.js
===================================================================
--- sandbox/madair/lib/OpenLayers/Layer/MapGuide.js	2007-11-08 20:52:07 UTC (rev 5153)
+++ sandbox/madair/lib/OpenLayers/Layer/MapGuide.js	2007-11-08 21:18:31 UTC (rev 5154)
@@ -61,6 +61,13 @@
         newArguments.push(name, url, params, options);
         OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
 
+        // unless explicitly set in options, if the layer is transparent, 
+        // it will be an overlay
+        if (options == null || options.isBaseLayer == null) {
+            this.isBaseLayer = ((this.params.transparent != "true") && 
+                                (this.params.transparent != true));
+        }
+
         if (arguments.length > 0) {
           if (this.options.singleTile) {
             this.session = params.session;
@@ -69,6 +76,9 @@
                            this.params,
                            this.SINGLE_TILE_PARAMS
                            );
+            if (!this.isBaseLayer) {
+              this.params.operation = "GETDYNAMICMAPOVERLAYIMAGE";
+            }
           } else {
             this.groupName = params.groupname;
             OpenLayers.Util.applyDefaults(
@@ -78,21 +88,47 @@
             this.setTileSize(new OpenLayers.Size(300,300)); //TBD: set this by options?
           }
         }
+    },
 
-        // unless explicitly set in options, if the layer is transparent, 
-        // it will be an overlay
-        if (options == null || options.isBaseLayer == null) {
-            this.isBaseLayer = ((this.params.transparent != "true") && 
-                                (this.params.transparent != true));
-        }
+    updateExtents: function(a) {
+      var center = this.map.getExtent().getCenterLonLat();
+      var mapSize = this.map.getCurrentSize();
+      var sParams = "operation=GETVISIBLEMAPEXTENT&version=1.0.0";
+      sParams += "&session="+this.session;
+      sParams += "&mapname="+this.mapName;
+      sParams += "&setdisplaydpi="+OpenLayers.DOTS_PER_INCH;   
+      sParams += "&setdisplayheight="+mapSize.h*this.ratio;
+      sParams += "&setdisplaywidth="+mapSize.w*this.ratio;
+      sParams += "&setviewcenterx="+center.lon;
+      sParams += "&setviewcentery="+center.lat;
+      sParams += "&setviewscale="+this.map.getScale();
+      if (this.options.showLayers) sParams += "&showlayers="+this.options.showLayers;
+      if (this.options.hideLayers) sParams += "&hidelayers="+this.options.hideLayers;
+      if (this.options.showGroups) sParams += "&showgroups="+this.options.showGroups;
+      if (this.options.hideGroups) sParams += "&hidegroups="+this.options.hideGroups;
+      if (this.options.refreshLayers) sParams += "&refreshlayers="+this.options.refreshLayers;
+      sParams += "&ts="+(new Date()).getTime();
+      // add in hidden/visible layers here?
+      new OpenLayers.Ajax.Request(this.url, 
+             {   parameters: sParams,
+                 onSuccess: this._getExtentSuccess, 
+                 onFailure: this._getExtentFailure,
+                 //requestHeaders: ['Authorization', 'Basic QW5vbnltb3VzOg=='], //TBD anon user base64 encoded
+                 asynchronous: false         //must be synchronous call to return control here
+              });
 
-        //create a session if not created
-        
     },
-
+    
     _getExtentSuccess: function(transport) {
-      this.extent = transport.responseXML;
+      //really this is a no-op, result is thrown away
+      var temp = transport.responseXML;
     },
+    
+    _getExtentFailure: function(r) {
+      //no-op
+    },
+    
+    
 	/**
     * @param {Object} obj
     *
@@ -141,25 +177,27 @@
         var mapSize = this.map.getCurrentSize();
 
         if (this.options.singleTile) {
-          //set up the call for GetVisibleMapExtent
+          //set up the call for GETMAPIMAGE or GETDYNAMICMAPOVERLAY
           var params = {};
 
-          if (!this.isBaseLayer) params.operation = "GETDYNAMICOVERLAYIMAGE";
-
           params.session = this.session;
           params.mapname = this.mapName;
-          params.locale = "en";
-          params.setdisplaydpi = OpenLayers.DOTS_PER_INCH;   
-          params.setdisplayheight = mapSize.h*this.ratio;
-          params.setdisplaywidth = mapSize.w*this.ratio;
-          params.setviewcenterx = center.lon;
-          params.setviewcentery = center.lat;
-          params.setviewscale = this.map.getScale();
-          if (this.options.showLayers) params.showlayers = this.options.showLayers;
-          if (this.options.hideLayers) params.hidelayers = this.options.hideLayers;
-          if (this.options.showGroups) params.showgroups = this.options.showGroups;
-          if (this.options.hideGroups) params.hidegroups = this.options.hideGroups;
-          if (this.options.refreshLayers) params.refreshlayers = this.options.refreshLayers;
+          if (this.isBaseLayer) {
+            params.locale = "en";
+            params.setdisplaydpi = OpenLayers.DOTS_PER_INCH;   
+            params.setdisplayheight = mapSize.h*this.ratio;
+            params.setdisplaywidth = mapSize.w*this.ratio;
+            params.setviewcenterx = center.lon;
+            params.setviewcentery = center.lat;
+            params.setviewscale = this.map.getScale();
+            if (this.options.showLayers) params.showlayers = this.options.showLayers;
+            if (this.options.hideLayers) params.hidelayers = this.options.hideLayers;
+            if (this.options.showGroups) params.showgroups = this.options.showGroups;
+            if (this.options.hideGroups) params.hidegroups = this.options.hideGroups;
+            if (this.options.refreshLayers) params.refreshlayers = this.options.refreshLayers;
+          } else {
+            this.updateExtents();
+          }
           params.ts = (new Date()).getTime();
 
           var url = this.getFullRequestString( params );
@@ -184,10 +222,6 @@
         return url;
     },
 
-    _requestMapImage: function(r) {
-      //no-op
-    },
-    
     /** 
      * getFullRequestString on MapGuide layers is special, because we 
      * do a regular expression replace on ',' in parameters to '+'.


More information about the Commits mailing list