diff --git a/src/ol/source/tiledwmssource.js b/src/ol/source/tiledwmssource.js index de94ee02e0..8a9ae3e153 100644 --- a/src/ol/source/tiledwmssource.js +++ b/src/ol/source/tiledwmssource.js @@ -40,6 +40,13 @@ ol.source.TileWMS = function(options) { */ this.params_ = options.params; + /** + * @private + * @type {string} + */ + this.coordKeyPrefix_ = ''; + this.resetCoordKeyPrefix_(); + if (goog.isDef(urls)) { var tileUrlFunctions = goog.array.map( urls, function(url) { @@ -108,8 +115,7 @@ goog.inherits(ol.source.TileWMS, ol.source.TileImage); * @inheritDoc */ ol.source.TileWMS.prototype.getKeyZXY = function(z, x, y) { - return goog.object.getValues(this.params_).join('/') + - goog.base(this, 'getKeyZXY', z, x, y); + return this.coordKeyPrefix_ + goog.base(this, 'getKeyZXY', z, x, y); }; @@ -146,11 +152,25 @@ ol.source.TileWMS.prototype.getFeatureInfoForPixel = }; +/** + * @private + */ +ol.source.TileWMS.prototype.resetCoordKeyPrefix_ = function() { + var i = 0; + var res = []; + for (var key in this.params_) { + res[i++] = key + '-' + this.params_[key]; + } + this.coordKeyPrefix_ = res.join('/'); +}; + + /** * Update the user-provided params. * @param {Object} params Params. */ ol.source.TileWMS.prototype.updateParams = function(params) { goog.object.extend(this.params_, params); + this.resetCoordKeyPrefix_(); this.dispatchChangeEvent(); }; diff --git a/src/ol/source/wmtssource.js b/src/ol/source/wmtssource.js index d65c6bdb4e..0a44eede2c 100644 --- a/src/ol/source/wmtssource.js +++ b/src/ol/source/wmtssource.js @@ -43,6 +43,13 @@ ol.source.WMTS = function(options) { */ this.dimensions_ = options.dimensions || {}; + /** + * @private + * @type {string} + */ + this.coordKeyPrefix_ = ''; + this.resetCoordKeyPrefix_(); + // FIXME: should we guess this requestEncoding from options.url(s) // structure? that would mean KVP only if a template is not provided. var requestEncoding = goog.isDef(options.requestEncoding) ? @@ -192,8 +199,20 @@ ol.source.WMTS.prototype.getDimensions = function() { * @inheritDoc */ ol.source.WMTS.prototype.getKeyZXY = function(z, x, y) { - return goog.object.getValues(this.dimensions_).join('/') + - goog.base(this, 'getKeyZXY', z, x, y); + return this.coordKeyPrefix_ + goog.base(this, 'getKeyZXY', z, x, y); +}; + + +/** + * @private + */ +ol.source.WMTS.prototype.resetCoordKeyPrefix_ = function() { + var i = 0; + var res = []; + for (var key in this.dimensions_) { + res[i++] = key + '-' + this.dimensions_[key]; + } + this.coordKeyPrefix_ = res.join('/'); }; @@ -203,6 +222,7 @@ ol.source.WMTS.prototype.getKeyZXY = function(z, x, y) { */ ol.source.WMTS.prototype.updateDimensions = function(dimensions) { goog.object.extend(this.dimensions_, dimensions); + this.resetCoordKeyPrefix_(); this.dispatchChangeEvent(); };