This change adds a lot of flexibility to working with tile layers: Sources where the server projection or tile grid do not matter can now be constructed without specifying a projection or tile grid. The tileUrlFunction/imageUrlFunction now also creates updated URLs when the params of the layer change, so things like mergeNewParams in ol2 will be possible. A nice side effect of this whole change is that there is no more duplicated code between tiled and single image WMS layers. While I was at it, I also fixed a WMS 1.1.1 axis order issue and incorrect STYLES params (STYLES=& instead of STYLES&).
39 lines
961 B
JavaScript
39 lines
961 B
JavaScript
goog.provide('ol.ImageUrlFunction');
|
|
goog.provide('ol.ImageUrlFunctionType');
|
|
|
|
goog.require('ol.Extent');
|
|
goog.require('ol.Size');
|
|
goog.require('ol.source.wms');
|
|
|
|
|
|
/**
|
|
* @typedef {function(ol.Extent, ol.Size, ol.Projection): (string|undefined)}
|
|
*/
|
|
ol.ImageUrlFunctionType;
|
|
|
|
|
|
/**
|
|
* @param {string} baseUrl Base URL (may have query data).
|
|
* @param {Object.<string, string|number>} params WMS parameters.
|
|
* @param {string=} opt_version WMS version.
|
|
* @return {ol.ImageUrlFunctionType} Image URL function.
|
|
*/
|
|
ol.ImageUrlFunction.createWMSParams =
|
|
function(baseUrl, params, opt_version) {
|
|
return function(extent, size, projection) {
|
|
return ol.source.wms.getUrl(
|
|
baseUrl, params, extent, size, projection, opt_version);
|
|
};
|
|
};
|
|
|
|
|
|
/**
|
|
* @param {ol.Extent} extent Extent.
|
|
* @param {ol.Size} size Size.
|
|
* @return {string|undefined} Image URL.
|
|
*/
|
|
ol.ImageUrlFunction.nullImageUrlFunction =
|
|
function(extent, size) {
|
|
return undefined;
|
|
};
|