Skip to content

Style-reload gap is shared: AisLayer, RouteLayer, DataLayers never re-add their layers after map.setStyle #153

Description

@DocGerd

Latent gap (found during PR #151 / issue #150)

Fixing #150 established that BoatMarker.tsx now re-adds its sources/layers on styledata after a style reload. Verifying the fix surfaced that the pattern it was told to mirror is itself one-shot: AisLayer.tsx's whenStyleReady uses once('load') and never re-adds after a mid-session map.setStyle(...). RouteLayer.tsx and DataLayers.tsx follow the same add-once idiom.

So after any future style reload, the AIS traffic layer, the route layers, and the data overlays (depth, seamarks, harbors) would all silently vanish until remount — same failure class as #150, three more sites.

Latent today: no code path calls map.setStyle mid-session. This is future-proofing for whenever one appears (e.g. a basemap style switch or theme-driven style swap).

Fix sketch

Extract the styledata-re-add pattern that PR #151 added to BoatMarker into ONE shared helper (e.g. lib/useStyleReadyLayers or a plain helper in MapView), and apply it to AisLayer, RouteLayer, and DataLayers — idempotent setup, latest-value refs, both listeners removed on unmount. Don't hand-copy the pattern three times.

Acceptance

After a programmatic map.setStyle() round-trip in each component's test (BoatMarker's simulateStyleReload fake from PR #151 is the reusable model), all sources/layers are present again; existing tests stay green; no behavior change outside the reload path.

Refs #150, PR #151 (premise correction in its body).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions