Viewport padding for loading (raster) tiles outside the viewport #3782
Unanswered
patrikschiller
asked this question in
Q&A
Replies: 1 comment
-
I would consider adding an option to the map called viewPortPadding and add some extra variables to trasform class that are specific to this case. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I already posted this issue to OpenStreetMaps Slack and closed the thread thinking, that I resolved the issue. However, I did not.
What I need is an option to load extra tiles outside the viewport. More specifically, I need to load tiles on those sides of the viewport, which are too close to the edge of the loaded tiles on that given side (the orange tiles in the following image):

That means I need to effectively expand the active area used for filtering out the non-visible tiles.
I looked through the relevant code, especially transform.ts, and found out that visible tiles are computed in Transform.coveringTiles() method via frustum culling. The problem is, that the same transform is used for tiles loading (filtering non-visible ones) and also for their rendering. So expanding the transform (viewport) results in loading more tiles, but also the map "zooms-out", which results in the same behavior as without the padding in the end.
Last week I came up with a temporary solution for the problem, where I created a copy (via Transform.clone()) of the original map.transform (which is initially the same object shared with map.painter.transform), expanded it by modifying its width and height properties, and set the original non-padded transform to the map.painter. So in this state, the padded transform (map.transform, having let's say 1200x1000) is used for the tile/viewport testing, and the map.painter.transform (which has the original resolution 1000x800) is used for rendering. Initially, it seemed to work perfectly until I spotted a few problems:
Regarding my problem, I have a few questions:
Thank you :)
Possible use-cases:
Beta Was this translation helpful? Give feedback.
All reactions