Change getUrlAsync parameters.
Instead of giving the function a bound, a scope, a property to update and a callback, only give the bound and a callback. When the url is retrieved by getUrlAsync, simply call the callback with the url as argument and let the caller manage this.
This commit is contained in:
@@ -205,12 +205,9 @@ OpenLayers.Layer.ArcIMS = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
|||||||
* Parameters:
|
* Parameters:
|
||||||
* bounds - {<OpenLayers.Bounds>} A bounds representing the bbox for the
|
* bounds - {<OpenLayers.Bounds>} A bounds representing the bbox for the
|
||||||
* request.
|
* request.
|
||||||
* scope - {Object} The scope of the callback method.
|
|
||||||
* prop - {String} The name of the property in the scoped object to
|
|
||||||
* recieve the image url.
|
|
||||||
* callback - {Function} Function to call when image url is retrieved.
|
* callback - {Function} Function to call when image url is retrieved.
|
||||||
*/
|
*/
|
||||||
getURLasync: function(bounds, scope, prop, callback) {
|
getURLasync: function(bounds, callback) {
|
||||||
bounds = this.adjustBounds(bounds);
|
bounds = this.adjustBounds(bounds);
|
||||||
|
|
||||||
// create an arcxml request to generate the image
|
// create an arcxml request to generate the image
|
||||||
@@ -239,11 +236,7 @@ OpenLayers.Layer.ArcIMS = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
|||||||
var axlResp = new OpenLayers.Format.ArcXML();
|
var axlResp = new OpenLayers.Format.ArcXML();
|
||||||
var arcxml = axlResp.read(doc);
|
var arcxml = axlResp.read(doc);
|
||||||
|
|
||||||
scope[prop] = this.getUrlOrImage(arcxml.image.output);
|
callback(this.getUrlOrImage(arcxml.image.output));
|
||||||
|
|
||||||
// call the callback function to recieve the updated property on the
|
|
||||||
// scoped object
|
|
||||||
callback.apply(scope);
|
|
||||||
},
|
},
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -168,15 +168,14 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
|||||||
this.layer.div.appendChild(this.getTile());
|
this.layer.div.appendChild(this.getTile());
|
||||||
if (this.layer.async) {
|
if (this.layer.async) {
|
||||||
// Asynchronous image requests call the asynchronous getURL method
|
// Asynchronous image requests call the asynchronous getURL method
|
||||||
// on the layer to fetch an image that covers 'this.bounds', in the scope of
|
// on the layer to fetch an image that covers 'this.bounds'.
|
||||||
// 'this', setting the 'url' property of the layer itself, and running
|
var id = this.asyncRequestId = (this.asyncRequestId || 0) + 1;
|
||||||
// the callback 'initImage' when the image request returns.
|
this.layer.getURLasync(this.bounds, OpenLayers.Function.bind(function(url) {
|
||||||
var myId = this.asyncRequestId = (this.asyncRequestId || 0) + 1;
|
if (id == this.asyncRequestId) {
|
||||||
this.layer.getURLasync(this.bounds, this, "url", function() {
|
this.url = url;
|
||||||
if (myId == this.asyncRequestId) {
|
|
||||||
this.initImage();
|
this.initImage();
|
||||||
}
|
}
|
||||||
});
|
}, this));
|
||||||
} else {
|
} else {
|
||||||
// synchronous image requests get the url immediately.
|
// synchronous image requests get the url immediately.
|
||||||
this.url = this.layer.getURL(this.bounds);
|
this.url = this.layer.getURL(this.bounds);
|
||||||
|
|||||||
@@ -85,9 +85,8 @@
|
|||||||
var layer = new OpenLayers.Layer.WMS(
|
var layer = new OpenLayers.Layer.WMS(
|
||||||
"Name",
|
"Name",
|
||||||
"http://labs.metacarta.com/TESTURL?",
|
"http://labs.metacarta.com/TESTURL?",
|
||||||
{layers: 'basic'}, {async: true, getURLasync: function(bounds, scope, url, callback) {
|
{layers: 'basic'}, {async: true, getURLasync: function(bounds, callback) {
|
||||||
scope.url = this.getURL(bounds);
|
callback(this.getURL(bounds));
|
||||||
callback.call(scope);
|
|
||||||
}}
|
}}
|
||||||
);
|
);
|
||||||
map.addLayer(layer);
|
map.addLayer(layer);
|
||||||
|
|||||||
Reference in New Issue
Block a user