Layer Management
"/home/yossef/notes/git/projects/maplibra/modules/Layer Management.md"
path: maplibra/modules/Layer Management.md
- **fileName**: Layer Management
- **Created on**: 2026-06-16 00:48:42
Layer Management
Purpose: Aggregates layer mixins that render indoor geometry, labels, doors, and debug overlays.
Related: ../Home.md, ../Architecture.md, ./Map Rendering.md, ./UI Components.md, ./MVF Loading.md
What It Does
LayerManager (src/layer-manager.js) is the central hub for all map layers. It composes behavior from focused mixins rather than growing into a monolithic class. It handles base layers, debug overlays, theme switching, and visibility toggles.
Layer Mixins
Base Layers (src/layers/base-layers.js)
addBuildingShell(floors)— Extruded building footprintrenderFloorData()— Floor-specific geometry, style layers, door features, labelsaddAnnotationNodes()— Entrance annotation markersaddPreparedLabels()— Precomputed label features from geo-prep worker
Debug Layers (lazy-loaded)
Debug layers are loaded on-demand via dynamic imports to keep the main bundle small:
addWallNodes()— Wall point visualizationaddStairsNodes()— Staircase connection pointsaddElevatorNodes()— Elevator connection pointsaddAnnotationNodes()— Entrance markersaddWalkableNodes()— Walkable grid pointsaddWalkableAreas()— Walkable polygon overlaysaddNonwalkableNodes()— Non-walkable pointsaddKindsNodes()— Semantic kind pointsaddEntranceAestheticNodes()— Entrance aesthetic pointsaddLocationMarkers()— POI location markers
Visibility Manager (src/layers/visibility-manager.js)
updateFloorVisibility(floorId)— Hides layers not on the current floorsetIndoorVisibility(visible)— Master indoor layer toggle- Zoom threshold enforcement (
MIN_ZOOM_INDOOR) - Annotation marker DOM visibility (separate from Mapbox layers)
Theme Switching
setTheme() and reapplyThemeColors() update layer colors without recreating sources or layers:
- Background color
- Building shell extrusion color
- Label text and halo colors
- Dynamic style layers (fill-extrusion colors with selected/hover states)
Important Files
src/layer-manager.js— Main class composing all mixinssrc/layers/base-layers.js— Building shell, floor renderingsrc/layers/visibility-manager.js— Floor filtering, zoom rulessrc/layers/debug-node-layers-part1.js— Wall, stairs, elevator, annotation layerssrc/layers/debug-node-layers-part2.js— Walkable, nonwalkable, kinds, entrance, location layerssrc/layers/debug/*.js— Individual debug layer mixinssrc/legend-toggle-manager.js— Legend panel toggle state and persistence
How It Connects
-
LayerManageris created bybootstrapMap()and used byFloorDataManagerto render floors -
UIManagertellsLayerManagerwhen to update visibility viaupdateFloorVisibility() -
PathfindingControllerusesPathRenderer(notLayerManager) for route lines -
Theme changes flow from
ThemeController→script.js→LayerManager -
Debug layers are loaded lazily when the developer legend is opened or
?debug=1is setcontinue:[[]]
before:[[]]