Add a getUrls Method to ol.source.XYZ
Added the getUrls method to get access to the url / urls property. When using a tileUrlFunction, getUrls should return null. This should fix issue #3886
This commit is contained in:
@@ -38,6 +38,12 @@ ol.source.XYZ = function(options) {
|
||||
tileSize: options.tileSize
|
||||
});
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!Array.<string>|null}
|
||||
*/
|
||||
this.urls_ = null;
|
||||
|
||||
goog.base(this, {
|
||||
attributions: options.attributions,
|
||||
crossOrigin: options.crossOrigin,
|
||||
@@ -62,6 +68,18 @@ ol.source.XYZ = function(options) {
|
||||
goog.inherits(ol.source.XYZ, ol.source.TileImage);
|
||||
|
||||
|
||||
/**
|
||||
* Return the URLs used for this XYZ source.
|
||||
* When a tileUrlFunction is used instead of url or urls,
|
||||
* null will be returned.
|
||||
* @return {!Array.<string>|null} URLs.
|
||||
* @api
|
||||
*/
|
||||
ol.source.XYZ.prototype.getUrls = function() {
|
||||
return this.urls_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the URL to use for requests.
|
||||
* @param {string} url URL.
|
||||
@@ -70,6 +88,7 @@ goog.inherits(ol.source.XYZ, ol.source.TileImage);
|
||||
ol.source.XYZ.prototype.setUrl = function(url) {
|
||||
this.setTileUrlFunction(ol.TileUrlFunction.createFromTemplates(
|
||||
ol.TileUrlFunction.expandUrl(url)));
|
||||
this.urls_ = [url];
|
||||
};
|
||||
|
||||
|
||||
@@ -79,4 +98,5 @@ ol.source.XYZ.prototype.setUrl = function(url) {
|
||||
*/
|
||||
ol.source.XYZ.prototype.setUrls = function(urls) {
|
||||
this.setTileUrlFunction(ol.TileUrlFunction.createFromTemplates(urls));
|
||||
this.urls_ = urls;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user