Fixes setUrl() for WMTS sources (ol.source.WMTS)

See Issue #5881: setUrl was inherited from ol.source UrlTile, which creates a wrong tileUrlFunction: The official WMTS URL Template variables were no longer replaced.
This commit is contained in:
Alexander Schenkel
2016-09-14 13:28:08 +02:00
committed by Frederic Junod
parent b4a5142aaa
commit c7cb26a066
2 changed files with 80 additions and 0 deletions

View File

@@ -148,6 +148,9 @@ ol.source.WMTS = function(options) {
});
}
// Store it as accessible function to be used later on:
this.createFromWMTSTemplate = createFromWMTSTemplate;
var tileUrlFunction = (urls && urls.length > 0) ?
ol.TileUrlFunction.createFromTileUrlFunctions(
urls.map(createFromWMTSTemplate)) :
@@ -175,6 +178,19 @@ ol.source.WMTS = function(options) {
};
ol.inherits(ol.source.WMTS, ol.source.TileImage);
/**
* Set the URLs to use for requests.
* URLs may contain OCG conform URL Template Variables: {TileMatrix}, {TileRow}, {TileCol}.
* @param {Array.<string>} urls URLs.
* @api stable
*/
ol.source.WMTS.prototype.setUrls = function(urls) {
this.urls = urls;
var key = urls.join('\n');
this.setTileUrlFunction(this.fixedTileUrlFunction ?
this.fixedTileUrlFunction.bind(this) :
ol.TileUrlFunction.createFromTileUrlFunctions(urls.map(this.createFromWMTSTemplate.bind(this))), key);
};
/**
* Get the dimensions, i.e. those passed to the constructor through the