More context for url functions
With this change, url functions are called in the scope of the source they are configured for. This allows us to simplify the url function generation for WMS, using a more generic createFromParamsFunction factory, and the source's new params member. Note that there is also a new url member for WMS sources. This is the WMS base url (the first one in case there is an array of urls for faster tile access). This can be used for accessing other WMS services (especially GetFeatureInfo).
This commit is contained in:
@@ -8,11 +8,13 @@ goog.require('ol.Extent');
|
||||
goog.require('ol.TileCoord');
|
||||
goog.require('ol.TileUrlFunction');
|
||||
goog.require('ol.source.ImageTileSource');
|
||||
goog.require('ol.source.wms');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {ol.source.IWMS}
|
||||
* @extends {ol.source.ImageTileSource}
|
||||
* @param {ol.source.TiledWMSOptions} tiledWMSOptions options.
|
||||
*/
|
||||
@@ -30,12 +32,13 @@ ol.source.TiledWMS = function(tiledWMSOptions) {
|
||||
if (goog.isDef(urls)) {
|
||||
var tileUrlFunctions = goog.array.map(
|
||||
urls, function(url) {
|
||||
return ol.TileUrlFunction.createWMSParams(
|
||||
url, tiledWMSOptions.params);
|
||||
return ol.TileUrlFunction.createFromParamsFunction(
|
||||
url, ol.source.wms.getUrl);
|
||||
});
|
||||
tileUrlFunction = ol.TileUrlFunction.createFromTileUrlFunctions(
|
||||
tileUrlFunctions);
|
||||
}
|
||||
|
||||
var transparent = goog.isDef(tiledWMSOptions.params['TRANSPARENT']) ?
|
||||
tiledWMSOptions.params['TRANSPARENT'] : true;
|
||||
var extent = tiledWMSOptions.extent;
|
||||
@@ -65,6 +68,16 @@ ol.source.TiledWMS = function(tiledWMSOptions) {
|
||||
return new ol.TileCoord(tileCoord.z, x, tileCoord.y);
|
||||
};
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
this.url = goog.isDef(urls) ? urls[0] : undefined;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
this.params = tiledWMSOptions.params;
|
||||
|
||||
goog.base(this, {
|
||||
attributions: tiledWMSOptions.attributions,
|
||||
crossOrigin: tiledWMSOptions.crossOrigin,
|
||||
|
||||
Reference in New Issue
Block a user