Map Rendering
"/home/yossef/notes/git/projects/maplibra/modules/Map Rendering.md"
path: maplibra/modules/Map Rendering.md
- **fileName**: Map Rendering
- **Created on**: 2026-06-16 00:48:42
Map Rendering
Purpose: Loads, prepares, caches, and renders floor-specific geometry on demand.
Related: ../Home.md, ../Architecture.md, ./Layer Management.md, ./MVF Loading.md, ./UI Components.md, ../flows/Map Render.md
What It Does
FloorDataManager (src/app/floor-data.js) is responsible for the complete floor render pipeline: loading raw floor data from the MVF bundle, optionally preparing it via a Web Worker, and painting it on the map.
Fast Render Strategy
The render pipeline uses a two-phase approach to keep floor changes responsive:
- Fast render — Paint raw geometry immediately without waiting for worker preparation
- Prepared swap — Once the geo-prep worker finishes, swap in precomputed style buckets, door features, and label features
This ensures the user sees floor geometry within milliseconds while the richer prepared version arrives shortly after.
Floor Data Cache
- LRU cache with configurable max size (default 4 floors)
- Memory pressure monitoring via
performance.memory(if available) - Eviction drops oldest floors when threshold exceeded
- Object URL cleanup on eviction
Memory Pressure
memoryThreshold— configurable byte limit (default 100MB)jsHeapSizeLimitcheck — evict when heap usage > 80%checkMemoryPressureruns on a 30-second interval
Geo Preparation
src/app/geo-prep.js (via Web Worker src/workers/geo-worker.js) precomputes:
styleLayers— bucketed features by style namedoorFeatures— door geometry for renderinglabelFeatures— text labels and iconspreparedform is faster to paint and update than raw geometry
Floor Request Cancellation
Only the latest floor request is allowed to paint the map. Older requests are cancelled via AbortController:
activeFloorRequestcounter increments on each requestrequestId !== activeFloorRequestaborts stale callbacksAbortControllerper floor for signal-based cancellation
Important Files
src/app/floor-data.js— FloorDataManager (load, cache, render, memory)src/app/geo-prep.js— Geometry preparation (style buckets, doors, labels)src/app/geo-prep-sync.js— Synchronous geo-prep fallbacksrc/workers/geo-worker.js— Web Worker for geo-prepsrc/layer-manager.js— LayerManager.renderFloorData()
How It Connects
-
FloorDataManageris created inscript.jswith references tomvfLoaderandlayerManager -
UIManagerdispatchesfloor-change-requested→script.jscallsfloorDataManager.loadAndRenderFloor() -
LayerManagerreceives both raw and prepared data viarenderFloorData() -
SearchBoxreceivesonLocationsAddedcallback when new floor locations are discovered -
Adjacent floor prefetching happens in startup tasks after the first render
continue:[[]]
before:[[]]