diff --git a/src/ol/map.js b/src/ol/map.js index b5dbc4304a..c594839c76 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -500,12 +500,16 @@ ol.Map.prototype.getTilePriority = if (!frameState.wantedTiles[tileSourceKey][coordKey]) { return ol.structs.PriorityQueue.DROP; } - // Prioritize tiles closest to the focus. The + 1 helps to prioritize tiles - // at higher zoom levels over tiles at lower zoom levels, even if the tile's - // center is close to the focus. + // Prioritize the highest zoom level tiles closest to the focus. + // Tiles at higher zoom levels are prioritized using Math.log(tileResolution). + // Within a zoom level, tiles are prioritized by the distance in pixels + // between the center of the tile and the focus. The factor of 65536 means + // that the prioritization should behave as desired for tiles up to + // 65536 * Math.log(2) = 45426 pixels from the focus. var deltaX = tileCenter.x - frameState.focus.x; var deltaY = tileCenter.y - frameState.focus.y; - return tileResolution * (deltaX * deltaX + deltaY * deltaY + 1); + return 65536 * Math.log(tileResolution) + + Math.sqrt(deltaX * deltaX + deltaY * deltaY) / tileResolution; }; diff --git a/src/ol/renderer/webgl/webglmaprenderer.js b/src/ol/renderer/webgl/webglmaprenderer.js index b9fa87ad7b..93b5073e61 100644 --- a/src/ol/renderer/webgl/webglmaprenderer.js +++ b/src/ol/renderer/webgl/webglmaprenderer.js @@ -176,7 +176,8 @@ ol.renderer.webgl.Map = function(container, map) { var tileResolution = /** @type {number} */ (element[2]); var deltaX = tileCenter.x - this.focus_.x; var deltaY = tileCenter.y - this.focus_.y; - return tileResolution * (deltaX * deltaX + deltaY * deltaY + 1); + return 65536 * Math.log(tileResolution) + + Math.sqrt(deltaX * deltaX + deltaY * deltaY) / tileResolution; }, this), /** * @param {Array} element Element.