Merge pull request #2336 from elemoine/seturl
Add ol.source.TileWMS#setUrls and setUrl
This commit is contained in:
@@ -56,9 +56,9 @@ ol.source.TileWMS = function(opt_options) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {Array.<string>|undefined}
|
* @type {!Array.<string>}
|
||||||
*/
|
*/
|
||||||
this.urls_ = urls;
|
this.urls_ = goog.isDefAndNotNull(urls) ? urls : [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -232,7 +232,7 @@ ol.source.TileWMS.prototype.getRequestUrl_ =
|
|||||||
pixelRatio, projection, params) {
|
pixelRatio, projection, params) {
|
||||||
|
|
||||||
var urls = this.urls_;
|
var urls = this.urls_;
|
||||||
if (!goog.isDef(urls) || goog.array.isEmpty(urls)) {
|
if (goog.array.isEmpty(urls)) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,7 +283,7 @@ ol.source.TileWMS.prototype.getRequestUrl_ =
|
|||||||
if (urls.length == 1) {
|
if (urls.length == 1) {
|
||||||
url = urls[0];
|
url = urls[0];
|
||||||
} else {
|
} else {
|
||||||
var index = goog.math.modulo(tileCoord.hash(), this.urls_.length);
|
var index = goog.math.modulo(tileCoord.hash(), urls.length);
|
||||||
url = urls[index];
|
url = urls[index];
|
||||||
}
|
}
|
||||||
return goog.uri.utils.appendParamsFromMap(url, params);
|
return goog.uri.utils.appendParamsFromMap(url, params);
|
||||||
@@ -309,7 +309,7 @@ ol.source.TileWMS.prototype.getTilePixelSize =
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the URLs used for this WMS source.
|
* Return the URLs used for this WMS source.
|
||||||
* @return {Array.<string>|undefined} URLs.
|
* @return {!Array.<string>} URLs.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.source.TileWMS.prototype.getUrls = function() {
|
ol.source.TileWMS.prototype.getUrls = function() {
|
||||||
@@ -323,10 +323,39 @@ ol.source.TileWMS.prototype.getUrls = function() {
|
|||||||
ol.source.TileWMS.prototype.resetCoordKeyPrefix_ = function() {
|
ol.source.TileWMS.prototype.resetCoordKeyPrefix_ = function() {
|
||||||
var i = 0;
|
var i = 0;
|
||||||
var res = [];
|
var res = [];
|
||||||
for (var key in this.params_) {
|
|
||||||
|
var j, jj;
|
||||||
|
for (j = 0, jj = this.urls_.length; j < jj; ++j) {
|
||||||
|
res[i++] = this.urls_[j];
|
||||||
|
}
|
||||||
|
|
||||||
|
var key;
|
||||||
|
for (key in this.params_) {
|
||||||
res[i++] = key + '-' + this.params_[key];
|
res[i++] = key + '-' + this.params_[key];
|
||||||
}
|
}
|
||||||
this.coordKeyPrefix_ = res.join('/');
|
|
||||||
|
this.coordKeyPrefix_ = res.join('#');
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string|undefined} url URL.
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
ol.source.TileWMS.prototype.setUrl = function(url) {
|
||||||
|
var urls = goog.isDef(url) ? ol.TileUrlFunction.expandUrl(url) : null;
|
||||||
|
this.setUrls(urls);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Array.<string>|undefined} urls URLs.
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
ol.source.TileWMS.prototype.setUrls = function(urls) {
|
||||||
|
this.urls_ = goog.isDefAndNotNull(urls) ? urls : [];
|
||||||
|
this.resetCoordKeyPrefix_();
|
||||||
|
this.dispatchChangeEvent();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user