Merge pull request #8642 from dimin/master
fixes for optional key passing, issue #8067 for tile sources
This commit is contained in:
@@ -23,6 +23,7 @@ import {wrapX, getForProjection as getTileGridForProjection} from '../tilegrid.j
|
|||||||
* @property {import("../tilegrid/TileGrid.js").default} [tileGrid]
|
* @property {import("../tilegrid/TileGrid.js").default} [tileGrid]
|
||||||
* @property {boolean} [wrapX=true]
|
* @property {boolean} [wrapX=true]
|
||||||
* @property {number} [transition]
|
* @property {number} [transition]
|
||||||
|
* @property {string} [key]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -83,7 +84,7 @@ class TileSource extends Source {
|
|||||||
* @private
|
* @private
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
this.key_ = '';
|
this.key_ = options.key || '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ import {getForProjection as getTileGridForProjection} from '../tilegrid.js';
|
|||||||
* world only, but they will be wrapped horizontally to render multiple worlds.
|
* world only, but they will be wrapped horizontally to render multiple worlds.
|
||||||
* @property {number} [transition] Duration of the opacity transition for rendering.
|
* @property {number} [transition] Duration of the opacity transition for rendering.
|
||||||
* To disable the opacity transition, pass `transition: 0`.
|
* To disable the opacity transition, pass `transition: 0`.
|
||||||
|
* @property {string} [key] Optional tile key for proper cache fetching
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -83,6 +84,7 @@ class TileImage extends UrlTile {
|
|||||||
urls: options.urls,
|
urls: options.urls,
|
||||||
wrapX: options.wrapX,
|
wrapX: options.wrapX,
|
||||||
transition: options.transition,
|
transition: options.transition,
|
||||||
|
key: options.key,
|
||||||
attributionsCollapsible: options.attributionsCollapsible
|
attributionsCollapsible: options.attributionsCollapsible
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import {getKeyZXY} from '../tilecoord.js';
|
|||||||
* @property {Array<string>} [urls]
|
* @property {Array<string>} [urls]
|
||||||
* @property {boolean} [wrapX=true]
|
* @property {boolean} [wrapX=true]
|
||||||
* @property {number} [transition]
|
* @property {number} [transition]
|
||||||
|
* @property {string} [key]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -49,6 +50,7 @@ class UrlTile extends TileSource {
|
|||||||
tilePixelRatio: options.tilePixelRatio,
|
tilePixelRatio: options.tilePixelRatio,
|
||||||
wrapX: options.wrapX,
|
wrapX: options.wrapX,
|
||||||
transition: options.transition,
|
transition: options.transition,
|
||||||
|
key: options.key,
|
||||||
attributionsCollapsible: options.attributionsCollapsible
|
attributionsCollapsible: options.attributionsCollapsible
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -82,6 +84,10 @@ class UrlTile extends TileSource {
|
|||||||
this.setUrl(options.url);
|
this.setUrl(options.url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.tileUrlFunction) {
|
||||||
|
this.setTileUrlFunction(options.tileUrlFunction, this.key_);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {!Object<string, boolean>}
|
* @type {!Object<string, boolean>}
|
||||||
@@ -157,14 +163,14 @@ class UrlTile extends TileSource {
|
|||||||
/**
|
/**
|
||||||
* Set the tile URL function of the source.
|
* Set the tile URL function of the source.
|
||||||
* @param {import("../Tile.js").UrlFunction} tileUrlFunction Tile URL function.
|
* @param {import("../Tile.js").UrlFunction} tileUrlFunction Tile URL function.
|
||||||
* @param {string=} opt_key Optional new tile key for the source.
|
* @param {string=} key Optional new tile key for the source.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
setTileUrlFunction(tileUrlFunction, opt_key) {
|
setTileUrlFunction(tileUrlFunction, key) {
|
||||||
this.tileUrlFunction = tileUrlFunction;
|
this.tileUrlFunction = tileUrlFunction;
|
||||||
this.tileCache.pruneExceptNewestZ();
|
this.tileCache.pruneExceptNewestZ();
|
||||||
if (typeof opt_key !== 'undefined') {
|
if (typeof key !== 'undefined') {
|
||||||
this.setKey(opt_key);
|
this.setKey(key);
|
||||||
} else {
|
} else {
|
||||||
this.changed();
|
this.changed();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user