Skip to content

ui/map/MapStyleManager

Classes

MapStyleManager

Defined in: ui/map/MapStyleManager.ts:32

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
new MapStyleManager(getMap, onBeforeStyleChange?): MapStyleManager;

Defined in: ui/map/MapStyleManager.ts:49

Parameters
getMap

() => Map$1 | null

onBeforeStyleChange?

() => void

Returns

MapStyleManager

Methods

resolveInitialStyle()
resolveInitialStyle(): string;

Defined in: ui/map/MapStyleManager.ts:60

Resolve the style the map should start with: the user's saved choice when present, the default basemap otherwise.

Returns

string

getCurrentStyle()
getCurrentStyle(): string;

Defined in: ui/map/MapStyleManager.ts:68

The style URL currently applied (or being applied).

Returns

string

changeStyle()
changeStyle(styleUrl): void;

Defined in: ui/map/MapStyleManager.ts:76

Change the map style

Parameters
styleUrl

string

URL of the new map style

Returns

void

armFirstLoadFallback()
armFirstLoadFallback(): void;

Defined in: ui/map/MapStyleManager.ts:126

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 fires if the style fetch rejects; on an air-gapped network it often just hangs for minutes, leaving a blank basemap. So probe the same style document with our own timeout, and if the probe fails while the map still has no loaded style, swap to the bundled offline basemap immediately. If the style loads first — or the user picks another style meanwhile — the probe result is ignored.

Returns

void

handleMapError()
handleMapError(e): void;

Defined in: ui/map/MapStyleManager.ts:166

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()
setupStyleSelector(): void;

Defined in: ui/map/MapStyleManager.ts:248

Set up map style selector event handlers This connects the HTML select element to the map style changing logic

Returns

void

hideMapStyleMessage()
hideMapStyleMessage(): void;

Defined in: ui/map/MapStyleManager.ts:462

Hide the map style message overlay

Returns

void