Respect fixed tile url functions when setting url(s)
This commit is contained in:
@@ -42,7 +42,6 @@ ol.source.TileArcGISRest = function(opt_options) {
|
||||
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
|
||||
tileGrid: options.tileGrid,
|
||||
tileLoadFunction: options.tileLoadFunction,
|
||||
tileUrlFunction: this.tileUrlFunction_.bind(this),
|
||||
url: options.url,
|
||||
urls: options.urls,
|
||||
wrapX: options.wrapX !== undefined ? options.wrapX : true
|
||||
@@ -138,13 +137,9 @@ ol.source.TileArcGISRest.prototype.getTilePixelRatio = function(pixelRatio) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||
* @param {number} pixelRatio Pixel ratio.
|
||||
* @param {ol.proj.Projection} projection Projection.
|
||||
* @return {string|undefined} Tile URL.
|
||||
* @private
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.source.TileArcGISRest.prototype.tileUrlFunction_ = function(tileCoord, pixelRatio, projection) {
|
||||
ol.source.TileArcGISRest.prototype.fixedTileUrlFunction = function(tileCoord, pixelRatio, projection) {
|
||||
|
||||
var tileGrid = this.getTileGrid();
|
||||
if (!tileGrid) {
|
||||
|
||||
@@ -46,7 +46,6 @@ ol.source.TileWMS = function(opt_options) {
|
||||
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
|
||||
tileGrid: options.tileGrid,
|
||||
tileLoadFunction: options.tileLoadFunction,
|
||||
tileUrlFunction: this.tileUrlFunction_.bind(this),
|
||||
url: options.url,
|
||||
urls: options.urls,
|
||||
wrapX: options.wrapX !== undefined ? options.wrapX : true
|
||||
@@ -301,13 +300,9 @@ ol.source.TileWMS.prototype.resetCoordKeyPrefix_ = function() {
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||
* @param {number} pixelRatio Pixel ratio.
|
||||
* @param {ol.proj.Projection} projection Projection.
|
||||
* @return {string|undefined} Tile URL.
|
||||
* @private
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.source.TileWMS.prototype.tileUrlFunction_ = function(tileCoord, pixelRatio, projection) {
|
||||
ol.source.TileWMS.prototype.fixedTileUrlFunction = function(tileCoord, pixelRatio, projection) {
|
||||
|
||||
var tileGrid = this.getTileGrid();
|
||||
if (!tileGrid) {
|
||||
|
||||
@@ -63,9 +63,8 @@ ol.source.UrlTile = function(options) {
|
||||
* @protected
|
||||
* @type {ol.TileUrlFunctionType}
|
||||
*/
|
||||
this.tileUrlFunction = options.tileUrlFunction ?
|
||||
options.tileUrlFunction :
|
||||
ol.TileUrlFunction.nullTileUrlFunction;
|
||||
this.tileUrlFunction =
|
||||
this.fixedTileUrlFunction || ol.TileUrlFunction.nullTileUrlFunction;
|
||||
|
||||
/**
|
||||
* @protected
|
||||
@@ -74,11 +73,7 @@ ol.source.UrlTile = function(options) {
|
||||
this.urls = null;
|
||||
|
||||
if (options.urls) {
|
||||
if (options.tileUrlFunction) {
|
||||
this.urls = options.urls;
|
||||
} else {
|
||||
this.setUrls(options.urls);
|
||||
}
|
||||
this.setUrls(options.urls);
|
||||
} else if (options.url) {
|
||||
this.setUrl(options.url);
|
||||
}
|
||||
@@ -90,6 +85,12 @@ ol.source.UrlTile = function(options) {
|
||||
goog.inherits(ol.source.UrlTile, ol.source.Tile);
|
||||
|
||||
|
||||
/**
|
||||
* @type {ol.TileUrlFunctionType|undefined}
|
||||
* @protected
|
||||
*/
|
||||
ol.source.UrlTile.prototype.fixedTileUrlFunction;
|
||||
|
||||
/**
|
||||
* Return the tile load function of the source.
|
||||
* @return {ol.TileLoadFunctionType} TileLoadFunction
|
||||
@@ -181,9 +182,10 @@ ol.source.UrlTile.prototype.setTileUrlFunction = function(tileUrlFunction) {
|
||||
* @api stable
|
||||
*/
|
||||
ol.source.UrlTile.prototype.setUrl = function(url) {
|
||||
this.setTileUrlFunction(ol.TileUrlFunction.createFromTemplates(
|
||||
ol.TileUrlFunction.expandUrl(url), this.tileGrid));
|
||||
this.urls = [url];
|
||||
var urls = ol.TileUrlFunction.expandUrl(url);
|
||||
this.setTileUrlFunction(this.fixedTileUrlFunction ||
|
||||
ol.TileUrlFunction.createFromTemplates(urls, this.tileGrid));
|
||||
};
|
||||
|
||||
|
||||
@@ -193,9 +195,9 @@ ol.source.UrlTile.prototype.setUrl = function(url) {
|
||||
* @api stable
|
||||
*/
|
||||
ol.source.UrlTile.prototype.setUrls = function(urls) {
|
||||
this.setTileUrlFunction(ol.TileUrlFunction.createFromTemplates(
|
||||
urls, this.tileGrid));
|
||||
this.urls = urls;
|
||||
this.setTileUrlFunction(this.fixedTileUrlFunction ||
|
||||
ol.TileUrlFunction.createFromTemplates(urls, this.tileGrid));
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user