Skip to content

ui/map/MapDisplay

Classes

MapDisplay

Defined in: ui/map/MapDisplay.ts:31

MapDisplay - Core map functionality

Handles MapLibre GL map initialization, base map management, and map style selection. This is the foundation for the radar display, providing the canvas for aircraft and other visualizations.

Constructors

Constructor
new MapDisplay(containerId?): MapDisplay;

Defined in: ui/map/MapDisplay.ts:69

Constructor

Parameters
containerId?

string = 'map'

The ID of the HTML element to contain the map

Returns

MapDisplay

Methods

initialize()
initialize(): void;

Defined in: ui/map/MapDisplay.ts:83

Initialize the map Creates and configures the MapLibre GL map instance

Returns

void

changeMapStyle()
changeMapStyle(styleUrl): void;

Defined in: ui/map/MapDisplay.ts:301

Change the map style (delegates to MapStyleManager)

Parameters
styleUrl

string

URL of the new map style

Returns

void

setupStyleSelector()
setupStyleSelector(): void;

Defined in: ui/map/MapDisplay.ts:308

Wire the settings-modal style selector (delegates to MapStyleManager)

Returns

void

toggleProjection()
toggleProjection(): void;

Defined in: ui/map/MapDisplay.ts:318

Toggle map projection between mercator and globe

Returns

void

getProjection()
getProjection(): "mercator" | "globe";

Defined in: ui/map/MapDisplay.ts:341

Get the current projection type

Returns

"mercator" | "globe"

getMap()
getMap(): Map$1 | null;

Defined in: ui/map/MapDisplay.ts:348

Get the MapLibre GL map instance

Returns

Map$1 | null

getMapTheme()
getMapTheme(): "light" | "dark";

Defined in: ui/map/MapDisplay.ts:359

Classify the active basemap as 'light' or 'dark' so overlays (e.g. the navdata renderer) can pick a palette that reads well against it. The known dark styles are the bundled offline-dark style, Dark Matter, and the OpenFreeMap dark/fiord styles; everything else (Positron, Bright, Liberty, MapTiler, custom URLs) uses the light palette.

Returns

"light" | "dark"

isInitialized()
isInitialized(): boolean;

Defined in: ui/map/MapDisplay.ts:370

Check if map is initialized

Returns

boolean

resize()
resize(): void;

Defined in: ui/map/MapDisplay.ts:387

Resize the map to its container, without flashing.

MapLibre's resize() reassigns the canvas width/height attributes, and a canvas assignment clears the drawing buffer even when the value is unchanged. A bare map.resize() therefore leaves a blank (background colored) canvas until MapLibre's next scheduled render frame — visible as an intermittent white flash. Following resize() with the synchronous redraw() repaints in the same frame, which is exactly what MapLibre's own container ResizeObserver does internally. Every manual resync (panel/layout changes, style swaps, DPR changes) must go through this method rather than calling map.resize() directly.

Returns

void

getCenter()
getCenter(): [number, number];

Defined in: ui/map/MapDisplay.ts:428

Get the map center

Returns

[number, number]

setCenter()
setCenter(
   lng, 
   lat, 
   zoom?
): void;

Defined in: ui/map/MapDisplay.ts:437

Set the map center

Parameters
lng

number

lat

number

zoom?

number

Returns

void

getZoom()
getZoom(): number;

Defined in: ui/map/MapDisplay.ts:451

Get the current zoom level

Returns

number

setZoom()
setZoom(zoom): void;

Defined in: ui/map/MapDisplay.ts:459

Set the zoom level

Parameters
zoom

number

Returns

void

zoomIn()
zoomIn(): void;

Defined in: ui/map/MapDisplay.ts:467

Zoom in by one level

Returns

void

zoomOut()
zoomOut(): void;

Defined in: ui/map/MapDisplay.ts:475

Zoom out by one level

Returns

void

panTo()
panTo(lat, lon): void;

Defined in: ui/map/MapDisplay.ts:483

Pan to a specific location (animated)

Parameters
lat

number

lon

number

Returns

void

getCurrentBounds()
getCurrentBounds(): number[] | null;

Defined in: ui/map/MapDisplay.ts:492

Get current map bounds Returns [west, south, east, north] for MCRE commands

Returns

number[] | null

fitBounds()
fitBounds(bounds, options?): void;

Defined in: ui/map/MapDisplay.ts:505

Fit the map to bounds

Parameters
bounds

[[number, number], [number, number]]

options?

FitBoundsOptions

Returns

void

onStyleChange()
onStyleChange(callback): void;

Defined in: ui/map/MapDisplay.ts:514

Set a callback to be invoked when the map style changes

Parameters
callback

() => void

Function to call when style loads

Returns

void

onBeforeStyleChange()
onBeforeStyleChange(callback): void;

Defined in: ui/map/MapDisplay.ts:524

Set a callback to be invoked right before every style swap starts (map.setStyle is about to be called), so listeners can tear down layers they attached to the outgoing style's sources first.

Parameters
callback

() => void

Function to call before the style change

Returns

void

setMapLoadCallback()
setMapLoadCallback(callback): void;

Defined in: ui/map/MapDisplay.ts:532

Set a callback to be invoked when the map finishes loading

Parameters
callback

() => void

Function to call when map loads

Returns

void

destroy()
destroy(): void;

Defined in: ui/map/MapDisplay.ts:544

Destroy the map and clean up resources

Returns

void