Respect fixed tile url functions when setting url(s)

This commit is contained in:
Andreas Hocevar
2016-01-13 17:09:23 +01:00
parent 1ad3d4e764
commit 4b441dc503
3 changed files with 18 additions and 26 deletions
+14 -12
View File
@@ -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));
};