remove synchronous behaviour for MapGuide overlay layers with newer MapGuide.

Patch by madair, reviewed by kseograf with comments, r=me (Closes #1756)


git-svn-id: http://svn.openlayers.org/trunk/openlayers@9005 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2009-03-11 06:19:41 +00:00
parent 718495bcec
commit a058555c62
+66 -24
View File
@@ -35,13 +35,34 @@ OpenLayers.Layer.MapGuide = OpenLayers.Class(OpenLayers.Layer.Grid, {
/** /**
* APIProperty: singleTile * APIProperty: singleTile
* {Boolean} use tile server or request single tile image. Note that using * {Boolean} use tile server or request single tile image.
* 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.
**/ **/
singleTile: false, singleTile: false,
/**
* APIProperty: useOverlay
* {Boolean} flag to indicate if the layer should be retrieved using
* GETMAPIMAGE (default) or using GETDYNAMICOVERLAY requests.
**/
useOverlay: false,
/**
* APIProperty: useAsyncOverlay
* {Boolean} indicates if the MapGuide site supports the asynchronous
* GETDYNAMICOVERLAY requests which is available in MapGuide Enterprise 2010
* and MapGuide Open Source v2.0.3 or higher. The newer versions of MG
* is called asynchronously, allows selections to be drawn separately from
* the map and offers styling options.
*
* With older versions of MapGuide, set useAsyncOverlay=false. Note that in
* this case a synchronous AJAX call is issued and the mapname and session
* parameters must be used to initialize the layer, not the mapdefinition
* parameter. Also note that this will issue 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.
**/
useAsyncOverlay: true,
/** /**
* Constant: TILE_PARAMS * Constant: TILE_PARAMS
* {Object} Hashtable of default parameter key/value pairs for tiled layer * {Object} Hashtable of default parameter key/value pairs for tiled layer
@@ -63,6 +84,18 @@ OpenLayers.Layer.MapGuide = OpenLayers.Class(OpenLayers.Layer.Grid, {
version: '1.0.0' version: '1.0.0'
}, },
/**
* Constant: OVERLAY_PARAMS
* {Object} Hashtable of default parameter key/value pairs for untiled layer
*/
OVERLAY_PARAMS: {
operation: 'GETDYNAMICMAPOVERLAYIMAGE',
format: 'PNG',
locale: 'en',
clip: '1',
version: '2.0.0'
},
/** /**
* Constant: FOLDER_PARAMS * Constant: FOLDER_PARAMS
* {Object} Hashtable of parameter key/value pairs which describe * {Object} Hashtable of parameter key/value pairs which describe
@@ -92,11 +125,9 @@ OpenLayers.Layer.MapGuide = OpenLayers.Class(OpenLayers.Layer.Grid, {
* For untiled base layers, specify either combination of 'mapName' and * For untiled base layers, specify either combination of 'mapName' and
* 'session', or 'mapDefinition' and 'locale'. * 'session', or 'mapDefinition' and 'locale'.
* *
* For untiled overlay layers (singleTile=true and isBaseLayer=false), * For older versions of MapGuide and overlay layers, set useAsyncOverlay
* mapName and session are required parameters for the Layer constructor. * to false and in this case mapName and session are required parameters
* Also NOTE: untiled overlay layers issues a synchronous AJAX request * for the constructor.
* 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.
* *
* NOTE: MapGuide OS uses a DPI value and degrees to meters conversion * NOTE: MapGuide OS uses a DPI value and degrees to meters conversion
* factor that are different than the defaults used in OpenLayers, * factor that are different than the defaults used in OpenLayers,
@@ -144,13 +175,26 @@ OpenLayers.Layer.MapGuide = OpenLayers.Class(OpenLayers.Layer.Grid, {
(this.transparent != true)); (this.transparent != true));
} }
if (options && options.useOverlay!=null) {
this.useOverlay = options.useOverlay;
}
//initialize for untiled layers //initialize for untiled layers
if (this.singleTile) { if (this.singleTile) {
if (this.useOverlay) {
OpenLayers.Util.applyDefaults(
this.params,
this.OVERLAY_PARAMS
);
if (!this.useAsyncOverlay) {
this.params.version = "1.0.0";
}
} else {
OpenLayers.Util.applyDefaults( OpenLayers.Util.applyDefaults(
this.params, this.params,
this.SINGLE_TILE_PARAMS this.SINGLE_TILE_PARAMS
); );
}
} else { } else {
//initialize for tiled layers //initialize for tiled layers
if (this.useHttpTile) { if (this.useHttpTile) {
@@ -223,20 +267,19 @@ OpenLayers.Layer.MapGuide = OpenLayers.Class(OpenLayers.Layer.Grid, {
var mapSize = this.map.getCurrentSize(); var mapSize = this.map.getCurrentSize();
if (this.singleTile) { if (this.singleTile) {
//set up the call for GETMAPIMAGE or GETDYNAMICMAPOVERLAY //set up the call for GETMAPIMAGE or GETDYNAMICMAPOVERLAY with
var params = {}; //dynamic map parameters
params.setdisplaydpi = OpenLayers.DOTS_PER_INCH; var params = {
params.setdisplayheight = mapSize.h*this.ratio; setdisplaydpi: OpenLayers.DOTS_PER_INCH,
params.setdisplaywidth = mapSize.w*this.ratio; setdisplayheight: mapSize.h*this.ratio,
params.setviewcenterx = center.lon; setdisplaywidth: mapSize.w*this.ratio,
params.setviewcentery = center.lat; setviewcenterx: center.lon,
params.setviewscale = this.map.getScale(); setviewcentery: center.lat,
setviewscale: this.map.getScale()
};
if (!this.isBaseLayer) { if (this.useOverlay && !this.useAsyncOverlay) {
// in this case the main image operation is remapped to this //first we need to call GETVISIBLEMAPEXTENT to set the extent
this.params.operation = "GETDYNAMICMAPOVERLAYIMAGE";
//but we first need to call GETVISIBLEMAPEXTENT to set the extent
var getVisParams = {}; var getVisParams = {};
getVisParams = OpenLayers.Util.extend(getVisParams, params); getVisParams = OpenLayers.Util.extend(getVisParams, params);
getVisParams.operation = "GETVISIBLEMAPEXTENT"; getVisParams.operation = "GETVISIBLEMAPEXTENT";
@@ -248,7 +291,6 @@ OpenLayers.Layer.MapGuide = OpenLayers.Class(OpenLayers.Layer.Grid, {
OpenLayers.Request.GET({url: url, async: false}); OpenLayers.Request.GET({url: url, async: false});
} }
//construct the full URL //construct the full URL
url = this.getFullRequestString( params ); url = this.getFullRequestString( params );
} else { } else {