[fusion-commits] r1583 - trunk/lib/OpenLayers
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Fri Oct 3 09:50:02 EDT 2008
Author: madair
Date: 2008-10-03 09:50:01 -0400 (Fri, 03 Oct 2008)
New Revision: 1583
Modified:
trunk/lib/OpenLayers/OpenLayers.js
Log:
re #120: patched version of OL which uses asynchronous calls for GETVISIBLEMAPEXTENT and supports the useOverlay flag
Modified: trunk/lib/OpenLayers/OpenLayers.js
===================================================================
--- trunk/lib/OpenLayers/OpenLayers.js 2008-10-03 13:08:06 UTC (rev 1582)
+++ trunk/lib/OpenLayers/OpenLayers.js 2008-10-03 13:50:01 UTC (rev 1583)
@@ -19477,10 +19477,7 @@
/**
* APIProperty: singleTile
- * {Boolean} use tile server or request single tile image. Note that using
- * singleTile *and* isBaseLayer false is *not recommend*: it uses synchronous
- * XMLHttpRequests to load tiles, and this will *lock up users browsers*
- * during requests if the server fails to respond.
+ * {Boolean} use tile server or request single tile image.
**/
singleTile: false,
@@ -19522,11 +19519,12 @@
* 'session', or 'mapDefinition' and 'locale'.
*
* For untiled overlay layers (singleTile=true and isBaseLayer=false),
- * mapName and session are required parameters for the Layer constructor.
- * Also NOTE: untiled overlay layers issues a synchronous AJAX request
- * before the image request can be issued so the users browser may lock
- * up if the MG Web tier does not respond in a timely fashion.
+ * mapName and session are required parameters for the Layer constructor.
*
+ * If the useOverlay flag is set to true, the image request will use
+ * GETDYNAMICOVERLAY instead of GETMAPIMAGE and some additonal parameters
+ * will be available as per http://trac.osgeo.org/mapguide/wiki/MapGuideRfc38
+ *
* NOTE: MapGuide OS uses a DPI value and degrees to meters conversion
* factor that are different than the defaults used in OpenLayers,
* so these must be adjusted accordingly in your application.
@@ -19650,28 +19648,18 @@
if (this.singleTile) {
//set up the call for GETMAPIMAGE or GETDYNAMICMAPOVERLAY
var params = {};
- 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.useOverlay) {
// in this case the main image operation is remapped to this
- this.params.operation = "GETDYNAMICMAPOVERLAYIMAGE";
+ params.operation = "GETDYNAMICMAPOVERLAYIMAGE";
- //but we first need to call GETVISIBLEMAPEXTENT to set the extent
- var getVisParams = {};
- getVisParams = OpenLayers.Util.extend(getVisParams, params);
- getVisParams.operation = "GETVISIBLEMAPEXTENT";
- getVisParams.version = "1.0.0";
- getVisParams.session = this.params.session;
- getVisParams.mapName = this.params.mapName;
- getVisParams.format = 'text/xml';
- url = this.getFullRequestString( getVisParams );
-
- OpenLayers.Request.GET({url: url, async: false});
+ } else {
+ 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();
}
//construct the full URL
@@ -19796,6 +19784,82 @@
};
},
+ /**
+ * Method: moveTo
+ * Override of OpenLayers.Grid.moveTo to call MGOS asynchronously for
+ * overlay layers.
+ * This function is called whenever the map is moved. All the moving
+ * of actual 'tiles' is done by the map, but moveTo's role is to accept
+ * a bounds and make sure the data that that bounds requires is pre-loaded.
+ *
+ * Parameters:
+ * bounds - {<OpenLayers.Bounds>}
+ * zoomChanged - {Boolean}
+ * dragging - {Boolean}
+ */
+ moveTo:function(bounds, zoomChanged, dragging) {
+ OpenLayers.Layer.HTTPRequest.prototype.moveTo.apply(this, arguments);
+
+ bounds = bounds || this.map.getExtent();
+
+ if (bounds != null) {
+
+ // if grid is empty or zoom has changed, we *must* re-tile
+ var forceReTile = !this.grid.length || zoomChanged;
+
+ // total bounds of the tiles
+ var tilesBounds = this.getTilesBounds();
+
+ if (this.singleTile) {
+
+ // We want to redraw whenever even the slightest part of the
+ // current bounds is not contained by our tile.
+ // (thus, we do not specify partial -- its default is false)
+ if ( forceReTile ||
+ (!dragging && !tilesBounds.containsBounds(bounds))) {
+ if (this.useOverlay) {
+ var center = bounds.getCenterLonLat();
+ var mapSize = this.map.getCurrentSize();
+
+ //first call GETVISIBLEMAPEXTENT to set the extent
+ //and continue on in the callback asynchronously
+ var getVisParams = {};
+ getVisParams.operation = "GETVISIBLEMAPEXTENT";
+ getVisParams.version = "1.0.0";
+ getVisParams.setdisplaydpi = OpenLayers.DOTS_PER_INCH;
+ getVisParams.setdisplayheight = mapSize.h*this.ratio;
+ getVisParams.setdisplaywidth = mapSize.w*this.ratio;
+ getVisParams.setviewcenterx = center.lon;
+ getVisParams.setviewcentery = center.lat;
+ getVisParams.setviewscale = this.map.getScale();
+ getVisParams.format = 'text/xml';
+ url = this.getFullRequestString( getVisParams );
+
+ OpenLayers.Request.GET({
+ url: url,
+ success: OpenLayers.Function.bind(this.initSingleTile, this, bounds)});
+
+ } else {
+ this.initSingleTile(bounds);
+ }
+ }
+ } else {
+
+ // if the bounds have changed such that they are not even
+ // *partially* contained by our tiles (IE user has
+ // programmatically panned to the other side of the earth)
+ // then we want to reTile (thus, partial true).
+ //
+ if (forceReTile || !tilesBounds.containsBounds(bounds, true)) {
+ this.initGriddedTiles(bounds);
+ } else {
+ //we might have to shift our buffer tiles
+ this.moveGriddedTiles(bounds);
+ }
+ }
+ }
+ },
+
CLASS_NAME: "OpenLayers.Layer.MapGuide"
});
/* ======================================================================
More information about the fusion-commits
mailing list