Merge pull request #4697 from gberaudo/bind_tileurl_function

Bind tileUrlFunction to the source
This commit is contained in:
Andreas Hocevar
2016-01-20 22:10:47 +01:00
+7 -4
View File
@@ -63,8 +63,9 @@ ol.source.UrlTile = function(options) {
* @protected * @protected
* @type {ol.TileUrlFunctionType} * @type {ol.TileUrlFunctionType}
*/ */
this.tileUrlFunction = this.tileUrlFunction = this.fixedTileUrlFunction ?
this.fixedTileUrlFunction || ol.TileUrlFunction.nullTileUrlFunction; this.fixedTileUrlFunction.bind(this) :
ol.TileUrlFunction.nullTileUrlFunction;
/** /**
* @protected * @protected
@@ -184,7 +185,8 @@ ol.source.UrlTile.prototype.setTileUrlFunction = function(tileUrlFunction) {
ol.source.UrlTile.prototype.setUrl = function(url) { ol.source.UrlTile.prototype.setUrl = function(url) {
this.urls = [url]; this.urls = [url];
var urls = ol.TileUrlFunction.expandUrl(url); var urls = ol.TileUrlFunction.expandUrl(url);
this.setTileUrlFunction(this.fixedTileUrlFunction || this.setTileUrlFunction(this.fixedTileUrlFunction ?
this.fixedTileUrlFunction.bind(this) :
ol.TileUrlFunction.createFromTemplates(urls, this.tileGrid)); ol.TileUrlFunction.createFromTemplates(urls, this.tileGrid));
}; };
@@ -196,7 +198,8 @@ ol.source.UrlTile.prototype.setUrl = function(url) {
*/ */
ol.source.UrlTile.prototype.setUrls = function(urls) { ol.source.UrlTile.prototype.setUrls = function(urls) {
this.urls = urls; this.urls = urls;
this.setTileUrlFunction(this.fixedTileUrlFunction || this.setTileUrlFunction(this.fixedTileUrlFunction ?
this.fixedTileUrlFunction.bind(this) :
ol.TileUrlFunction.createFromTemplates(urls, this.tileGrid)); ol.TileUrlFunction.createFromTemplates(urls, this.tileGrid));
}; };