Excessive vector tile requests with modified tileUrlFunction
See original GitHub issueDescribe the bug
I am using a modified tileUrlFunction
to request vector tiles from variable paths depending on the current zoom level and context (e.g. UI selection). However, it seems that vector tiles are requested multiple times in this setup. This can be seen by returning the values calculated within the tileUrlFunction
to the console. It is also noticeable visually: On zoom, tiles from several paths are loaded until they are overwritten by the correct tile at last. I suspect this might be one reason for the poor performance I’m experiencing when using vector tiles (cf. my question at GIS Stackexchange).
Using the same tileUrlFunction
with raster tiles works as expected, requesting each tile only once.
To Reproduce Steps to reproduce the behavior:
- Use a modified
tileUrlFunction
to request vector tiles depending on current zoom level and context. At each call of the function, output the parameters of the requested tile to the console.
var selectedMode = ...;
function getVectorTilePath() { ... }
function loadTiles(tileCoordinate) {
const z = tileCoordinate[0];
const x = tileCoordinate[1];
const y = tileCoordinate[2];
var path = getVectorTilePath(z, selectedMode);
console.log("z:", z, "x:", x, "y:", y, "path:", path);
return "mytileserver/"
+ path
+ "/" + z + "/" + x + "/" + y
+ ".pbf";
}
var vt = new VectorTileLayer({
source: new VectorTileSource({
format: new MVT(),
tileGrid: ...,
tileUrlFunction: loadTiles,
zDirection: 0,
transition: 0,
}),
preload: 0,
useInterimTilesOnError: false,
style: ...,
})
var map = new Map({
target: 'map',
loadTilesWhileAnimating: true,
loadTilesWhileInteracting: true,
projection: ...,
layers: [ vt ],
view: ...,
});
- The output of the console (after a single zoom step) indicates that tiles are requested multiple times. Tiles might be excessively requested with a different path attribute (see above). Also, completely identical tiles seem to be requested multiple times.
z: 3 x: 11 y: 2 path: path1
z: 3 x: 10 y: 2 path: path1
z: 3 x: 11 y: 2 path: path1
z: 3 x: 10 y: 2 path: path1
z: 2 x: 5 y: 0 path: path0
z: 1 x: 2 y: 0 path: path0
z: 2 x: 5 y: 0 path: path0
z: 3 x: 11 y: 2 path: path1
z: 1 x: 2 y: 0 z: 1 path: path0
z: 3 x: 11 y: 2 z: 3 path: path1
This is, in principle, what the output looks like, path0
representing tiles usually requested at lower zoom levels z
than those with path1
. (The console output is much larger but I have modified it so that duplicates are better visible). When I use the same function with raster tiles, it works as intended without duplicate requests.
Expected behavior On an interaction with the map, request each vector tile only once and using the correct path only.
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (5 by maintainers)
Top GitHub Comments
Thanks for your continued effort on this. Looks like there is a bug indeed. I have a rough idea where it could come from - the
getSourceTiles()
function inol/VectorRenderTile
.I won’t be able to fix this before May, so if someone else wants to take a look, a pull request would be much appreciated.
I think what you’re observing is not related to the custom
tileUrlFunction
. I’m not sure about the reason for the repeated requests for the same tile, but the high amount of requests for lower resolution tiles might be reduced by #12137.