Skip to content

Fix map tiles vanishing on narrow viewports with top-down view#9228

Draft
markschlosseratbentley wants to merge 11 commits into
masterfrom
markschlosser/fix-maps-loading-saved-view
Draft

Fix map tiles vanishing on narrow viewports with top-down view#9228
markschlosseratbentley wants to merge 11 commits into
masterfrom
markschlosser/fix-maps-loading-saved-view

Conversation

@markschlosseratbentley
Copy link
Copy Markdown
Contributor

@markschlosseratbentley markschlosseratbentley commented Apr 23, 2026

Previously, background map tiles disappeared entirely when the viewport was narrow (~≤162px wide) and the camera was in a near-top-down orientation. This was reported on iTwin.js apps using Google Maps on mobile devices, but also reproduces with Bing Maps. It seems to be a core map tile selection bug, not provider-specific.

Problem

The pixel-size calculation for globe (non-planar) map tiles underestimates their screen coverage due to two compounding errors:

  1. getSizeProjectionCorners returned corners from the tile's ECEF axis-aligned bounding box: a flat rectangle at one Z-plane deep inside the Earth that bears no geometric relationship to the tile's angular extent on the sphere
  2. The base getPixelSizeFromProjection uses the geometric mean of the projected X and Y ranges. Because longitude lines converge toward the poles, globe tiles project anisotropically (more rectangular than square), meaning the geometric mean systematically underestimates screen coverage

The combined underestimate causes the calculated pixel size to drop below map tiles' maximumSize (512 px) when the viewport is narrow, halting refinement at depth 3 (the minimum displayable depth in the map tile tree). Because structural ancestors (depths 0–2) carry no imagery and the child-selection mechanism is all-or-nothing, nothing renders and the viewport goes black.

Fix

  • Changes to MapTile.getSizeProjectionCorners: for non-planar tiles, use the origins of the tile's 4 corner rays. These are closer to the actual tile size than points from the AABB, making the whole process more accurate.
  • New MapTile.computeVisibilityFactor override method: if the visibility factor > 0, do a second pass that uses the maximum tile dimension (in either width or height, whichever is highest) instead of its TileDrawArgs.getPixelSizeFromProjection

Testing

  • Manually tested with an iModel that previously demonstrated the bug
  • Performance: max may request ~1 extra refinement level for significantly anisotropic tiles at high latitudes (>55°)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants