ui/map/MapStyleManager¶
Classes¶
MapStyleManager¶
Defined in: ui/map/MapStyleManager.ts:31
MapStyleManager - basemap style selection, persistence, and offline fallback, extracted from MapDisplay.
Owns the saved-style storage key, the settings-modal style selector wiring, and the one-shot fallback to the bundled offline style when the remote basemap is unreachable.
Constructors¶
Constructor¶
Defined in: ui/map/MapStyleManager.ts:50
Parameters¶
getMap¶
() => Map$1 | null
onBeforeStyleChange?¶
() => void
Returns¶
Methods¶
resolveInitialStyle()¶
Defined in: ui/map/MapStyleManager.ts:63
Resolve the style the map should start with: the user's saved choice when present, the default basemap otherwise.
Returns¶
string
getCurrentStyle()¶
Defined in: ui/map/MapStyleManager.ts:71
The style URL currently applied (or being applied).
Returns¶
string
changeStyle()¶
Defined in: ui/map/MapStyleManager.ts:79
Change the map style
Parameters¶
styleUrl¶
string
URL of the new map style
Returns¶
void
armFirstLoadFallback()¶
Defined in: ui/map/MapStyleManager.ts:132
Make the first-load offline fallback deterministic. Call once right after the map is constructed, when the initial style may be remote.
The 'error'-event fallback in handleMapError only helps when the failed style fetch actually rejects. On an air-gapped network the request to the basemap CDN often just hangs (dropped packets, DNS blackhole, proxy sink) — no error event ever fires, the map never gets a style, and the user stares at a blank basemap until the OS connect timeout (minutes) finally rejects the fetch. Only then does the fallback fire and persist the offline style, which is why a later reload "fixed" it.
So probe the same style document the map is fetching, with our own timeout. If the probe fails (network error, timeout, or HTTP error) while the map still has no loaded style, swap to the bundled offline basemap immediately. If the map's style loads first — or the user picks a different style meanwhile — the probe result is ignored.
Returns¶
void
handleMapError()¶
Defined in: ui/map/MapStyleManager.ts:172
Route a MapLibre 'error' event: fall back to the offline basemap on network failures, suppress known non-critical errors, log the rest.
Parameters¶
e¶
MapErrorEvent
Returns¶
void
setupStyleSelector()¶
Defined in: ui/map/MapStyleManager.ts:265
Set up map style selector event handlers This connects the HTML select element to the map style changing logic
Returns¶
void
hideMapStyleMessage()¶
Defined in: ui/map/MapStyleManager.ts:478
Hide the map style message overlay
Returns¶
void