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:
@@ -35,13 +35,34 @@ OpenLayers.Layer.MapGuide = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
|
||||
/**
|
||||
* 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,
|
||||
|
||||
/**
|
||||
* 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
|
||||
* {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'
|
||||
},
|
||||
|
||||
/**
|
||||
* 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
|
||||
* {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
|
||||
* '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.
|
||||
* For older versions of MapGuide and overlay layers, set useAsyncOverlay
|
||||
* to false and in this case mapName and session are required parameters
|
||||
* for the constructor.
|
||||
*
|
||||
* NOTE: MapGuide OS uses a DPI value and degrees to meters conversion
|
||||
* 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));
|
||||
}
|
||||
|
||||
if (options && options.useOverlay!=null) {
|
||||
this.useOverlay = options.useOverlay;
|
||||
}
|
||||
|
||||
//initialize for untiled layers
|
||||
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(
|
||||
this.params,
|
||||
this.SINGLE_TILE_PARAMS
|
||||
);
|
||||
|
||||
}
|
||||
} else {
|
||||
//initialize for tiled layers
|
||||
if (this.useHttpTile) {
|
||||
@@ -223,20 +267,19 @@ OpenLayers.Layer.MapGuide = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
var mapSize = this.map.getCurrentSize();
|
||||
|
||||
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();
|
||||
//set up the call for GETMAPIMAGE or GETDYNAMICMAPOVERLAY with
|
||||
//dynamic map parameters
|
||||
var params = {
|
||||
setdisplaydpi: OpenLayers.DOTS_PER_INCH,
|
||||
setdisplayheight: mapSize.h*this.ratio,
|
||||
setdisplaywidth: mapSize.w*this.ratio,
|
||||
setviewcenterx: center.lon,
|
||||
setviewcentery: center.lat,
|
||||
setviewscale: this.map.getScale()
|
||||
};
|
||||
|
||||
if (!this.isBaseLayer) {
|
||||
// in this case the main image operation is remapped to this
|
||||
this.params.operation = "GETDYNAMICMAPOVERLAYIMAGE";
|
||||
|
||||
//but we first need to call GETVISIBLEMAPEXTENT to set the extent
|
||||
if (this.useOverlay && !this.useAsyncOverlay) {
|
||||
//first we need to call GETVISIBLEMAPEXTENT to set the extent
|
||||
var getVisParams = {};
|
||||
getVisParams = OpenLayers.Util.extend(getVisParams, params);
|
||||
getVisParams.operation = "GETVISIBLEMAPEXTENT";
|
||||
@@ -248,7 +291,6 @@ OpenLayers.Layer.MapGuide = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
|
||||
OpenLayers.Request.GET({url: url, async: false});
|
||||
}
|
||||
|
||||
//construct the full URL
|
||||
url = this.getFullRequestString( params );
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user