Merge pull request #2190 from Aiosa/master

Provide deafult getTileHashKey implementation for "TileSource" object if missing
This commit is contained in:
Ian Gilman 2022-08-23 14:01:45 -07:00 committed by GitHub
commit 5e7ce1afa5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -129,7 +129,7 @@ $.Tile = function(level, x, y, bounds, exists, url, context2D, loadWithAjax, aja
this.ajaxHeaders = ajaxHeaders; this.ajaxHeaders = ajaxHeaders;
if (cacheKey === undefined) { if (cacheKey === undefined) {
$.console.error("Tile constructor needs 'cacheKey' variable: creation tile cache" + $.console.warn("Tile constructor needs 'cacheKey' variable: creation tile cache" +
" in Tile class is deprecated. TileSource.prototype.getTileHashKey will be used."); " in Tile class is deprecated. TileSource.prototype.getTileHashKey will be used.");
cacheKey = $.TileSource.prototype.getTileHashKey(level, x, y, url, ajaxHeaders, postData); cacheKey = $.TileSource.prototype.getTileHashKey(level, x, y, url, ajaxHeaders, postData);
} }

View File

@ -688,11 +688,14 @@ $.TileSource.prototype = {
* @param {*} postData data the tile was fetched with (type depends on getTilePostData(..) return type) * @param {*} postData data the tile was fetched with (type depends on getTilePostData(..) return type)
*/ */
getTileHashKey: function(level, x, y, url, ajaxHeaders, postData) { getTileHashKey: function(level, x, y, url, ajaxHeaders, postData) {
if (ajaxHeaders) { function withHeaders(hash) {
return url + "+" + JSON.stringify(ajaxHeaders); return ajaxHeaders ? hash + "+" + JSON.stringify(ajaxHeaders) : hash;
} else {
return url;
} }
if (typeof url !== "string") {
return withHeaders(level + "/" + x + "_" + y);
}
return withHeaders(url);
}, },
/** /**