diff --git a/lib/OpenLayers/Layer/HTTPRequest.js b/lib/OpenLayers/Layer/HTTPRequest.js index ee149f540b..11d752fe15 100644 --- a/lib/OpenLayers/Layer/HTTPRequest.js +++ b/lib/OpenLayers/Layer/HTTPRequest.js @@ -93,7 +93,7 @@ OpenLayers.Layer.HTTPRequest.prototype = }, - /** combine the layer's url with its params and these newParams. + /** combine url with layer's params and these newParams. * * does checking on the serverPath variable, allowing for cases when it * is supplied with trailing ? or &, as well as cases where not. @@ -102,13 +102,17 @@ OpenLayers.Layer.HTTPRequest.prototype = * "server?key1=value1&key2=value2&key3=value3" * * @param {Object} newParams + * @param {String} altUrl Use this as the url instead of the layer's url * * @type String */ - getFullRequestString:function(newParams) { + getFullRequestString:function(newParams, altUrl) { - //requestString always starts with url - var requestString = this.url; + // use layer's url unless altUrl passed in + var url = (altUrl == null) ? this.url : altUrl; + + // requestString always starts with url + var requestString = url; // create a new params hash with all the layer params and the // new params together. then convert to string diff --git a/lib/OpenLayers/Layer/WFS.js b/lib/OpenLayers/Layer/WFS.js index 4b707ade52..3089e31e12 100644 --- a/lib/OpenLayers/Layer/WFS.js +++ b/lib/OpenLayers/Layer/WFS.js @@ -110,11 +110,20 @@ OpenLayers.Layer.WFS.prototype = * @type OpenLayers.Tile.WFS */ addTile:function(bounds, position) { - var url = this.getFullRequestString( - { BBOX:bounds.toBBOX() }); + var urls = new Array(); + + //add standard URL + urls.push( this.getFullRequestString( { BBOX:bounds.toBBOX() }) ); + + // if there are more urls, add them. + for(var i=0; i < this.urls.length; i++) { + var newUrl = this.getFullRequestString( { BBOX:bounds.toBBOX() }, + this.urls[i] ); + urls.push(newUrl); + } return new OpenLayers.Tile.WFS(this, position, bounds, - url, this.tileSize); + urls, this.tileSize); }, diff --git a/lib/OpenLayers/Tile/WFS.js b/lib/OpenLayers/Tile/WFS.js index 486d1384cd..53f5830130 100644 --- a/lib/OpenLayers/Tile/WFS.js +++ b/lib/OpenLayers/Tile/WFS.js @@ -19,12 +19,14 @@ OpenLayers.Tile.WFS.prototype = * @param {OpenLayers.Layer} layer * @param {OpenLayers.Pixel} position * @param {OpenLayers.Bounds} bounds - * @param {String} url + * @param {Array} urls * @param {OpenLayers.Size} size */ - initialize: function(layer, position, bounds, url, size) { + initialize: function(layer, position, bounds, urls, size) { + var newArguments = [layer, position, bounds, null, size]; OpenLayers.Tile.prototype.initialize.apply(this, arguments); - + + this.urls = urls; this.features = new Array(); }, @@ -57,13 +59,17 @@ OpenLayers.Tile.WFS.prototype = if (!this.loaded) { - if (this.url != "") { + if (this.urls != null) { // TODO: Hmmm, this stops multiple loads of the data when a // result isn't immediately retrieved, but it's hacky. // Do it better. this.loaded = true; - OpenLayers.loadURL(this.url, null, this, success, failure); + + for(var i=0; i < this.urls.length; i++) { + OpenLayers.loadURL(this.urls[i], null, this, + success, failure); + } } } }, diff --git a/tests/test_Layer_HTTPRequest.html b/tests/test_Layer_HTTPRequest.html index 047fbafa6e..f5a08bc84a 100644 --- a/tests/test_Layer_HTTPRequest.html +++ b/tests/test_Layer_HTTPRequest.html @@ -113,7 +113,7 @@ tParams = { layers: 'basic', format: 'image/png'}; - t.plan( 7 ); + t.plan( 8 ); // without ? tUrl = "http://octo.metacarta.com/cgi-bin/mapserv"; @@ -158,6 +158,12 @@ layers:"road" } ); t.eq(str, "http://octo.metacarta.com/cgi-bin/mapserv?param1=5&chicken=6&layers=road", "getFullRequestString() works for layer with null params passing in new params"); + // with specified altUrl parameter + tUrl = "http://octo.metacarta.com/cgi-bin/mapserv"; + layer = new OpenLayers.Layer.HTTPRequest(name, "chicken", tParams, null); + str = layer.getFullRequestString(null, tUrl); + t.eq(str, "http://octo.metacarta.com/cgi-bin/mapserv?layers=basic&format=image/png", "getFullRequestString() works for url sans ?"); + } function test_99_Layer_HTTPRequest_destroy (t) {