Repository navigation
refactor(map): consolidate overlay style lifecycle - #493
Merged
Merged
Conversation
Overlays now reconcile through one declarative layer group or a cached style subscription instead of hand-written styledata listeners. - subscribeStyleLoaded probes the parsed style once per stylesheet; layer ordering and label localization read layers directly instead of serializing the whole style after every mutation. - applyGroup updates paint, layout, filter and zoom range in place, starts asynchronous image loads once per style, and useMapLayerGroup skips passes while a replacement stylesheet is parsing. - removeSlottedLayers and useSlottedLayersCleanup replace hand-written teardowns; imperative overlays now remove their layers on unmount. - Most overlays and several app layers move to useMapLayerGroup; the standalone mini-maps share useStandaloneMap. - The slot uniqueness scan now reads group descriptors and found pre-existing ties, resolved with distinct orders.
Medformatik
force-pushed
the
refactor/map-style-sync-cleanup
branch
from
October 17, 2026 06:49
bc533f8 to
f616c66
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed and why
Follow-up to
fix(map): install layers without waiting for source tiles. That fix was correct, but it moved about 20 overlays ontosubscribeStyleLoaded, which calledgetStyle()(a full serialization of the style) on everystyledataevent, for every subscriber. It also left a lot of hand-written lifecycle code in place. This PR consolidates map layer lifecycles on shared primitives.Hot paths.
subscribeStyleLoadedchecks whether the stylesheet is parsed once per stylesheet, and invalidates onstyledataloading. Layer ordering (addLayerInSlotandanchorMapLayers) and map label localization now readgetLayersOrder()andgetLayer()instead of copying the whole style.useMapLayerGroup/applyGroup.EMPTY_FEATURE_COLLECTIONgives sources fed by the GeoJSON data bridge a stable placeholder.Teardown.
removeSlottedLayersreplacesremoveLayerAndSourceand about 20 hand-written remove/unregister blocks, and keeps sources that another layer still reads.useSlottedLayersCleanupremoves an imperative overlay's layers when it unmounts. Before, they were left on the map when an integration was switched off.Migrations to
useMapLayerGroup:Raster acquisition, basemap-vector, WebGL and basemap-relative layers stay imperative on
subscribeStyleLoaded. The three standalone mini-maps shareuseStandaloneMap. The integration docs now explain how to choose between these primitives.Guards.
main, resolved by giving the colliding layers distinct orders. Half-step orders keep each layer next to the one it used to tie with.isStyleLoaded(), idle waits and rawstyledatalisteners in integrations.Fixes that fall out of this.
minZoomor colour now reaches the installed layer.styledataevents.Verification
Checks recorded during the original PR:
Validated locally:
lint (0 errors), full type checks, and the full Vitest suite in the pre-push hook. Three independent read-only reviews found no high-confidence regressions. All checks used the fake test map; nothing has been verified in a browser against real MapLibre style swaps.
Release and upgrade impact
Shared map-layer lifecycle refactor. Imperative raster/vector/WebGL paths keep their stated boundaries. Real-browser MapLibre style-swap verification was not performed.