Skip to content

Cull offscreen map markers to keep panning performant#5

Merged
dfalling merged 1 commit into
mainfrom
map-loading-and-merge
May 25, 2026
Merged

Cull offscreen map markers to keep panning performant#5
dfalling merged 1 commit into
mainfrom
map-loading-and-merge

Conversation

@dfalling
Copy link
Copy Markdown
Owner

Summary

  • <Marker> from @maplibre/maplibre-react-native is a native View — MapLibre reprojects every marker on every camera frame, with no viewport culling. As the accumulator grew across pans, the offscreen markers were degrading performance.
  • Filter elementsById to the last-known viewport bounds before rendering. Cached entries stay in memory, so panning back to a previously-visited area shows pins instantly.

Notes

  • Explored switching to a GeoJSONSource + symbol layer (GPU-rendered, native viewport culling, free clustering) but MapLibre Native pre-rasterizes glyphs server-side and OpenFreeMap's font stack doesn't ship emoji ranges, so text-field: ['get', 'icon'] 404s on every emoji codepoint. Twemoji-via-iconImage is a viable future path if marker counts get large enough to matter.

Test plan

  • Pan around the map repeatedly in the emulator; pins outside the viewport should disappear and re-render on pan-back without a network round trip
  • Zoom in/out; visible pins should update on region settle
  • No regressions to the initial location centering or in-flight fetch behavior

🤖 Generated with Claude Code

@dfalling dfalling enabled auto-merge (squash) May 25, 2026 20:39
Marker is a native View that reprojects every camera frame even when
offscreen, so the accumulated set was growing unbounded. Filter to the
last-known viewport bounds before rendering; cached pins outside the
viewport stay in memory and reappear instantly on pan-back.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dfalling dfalling force-pushed the map-loading-and-merge branch from af7dcf9 to 505a772 Compare May 25, 2026 20:40
@dfalling dfalling merged commit 59a10e1 into main May 25, 2026
2 checks passed
@dfalling dfalling deleted the map-loading-and-merge branch May 25, 2026 20:40
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.

1 participant