Skip to content

utils/maplibre

Variables

DRAWING_CURSOR

const DRAWING_CURSOR: "crosshair" = 'crosshair';

Defined in: utils/maplibre.ts:20

Canvas cursor used by every interactive map-drawing mode (console map picker, shape/route drawing, aircraft creation). Centralised here so all drawing modes share one consistent pointer. Assign the empty string to restore MapLibre's default cursor when leaving a drawing mode.

Functions

ensureGeoJSONSource()

function ensureGeoJSONSource(
   map, 
   sourceId, 
   extra?
): void;

Defined in: utils/maplibre.ts:22

Parameters

map

Map$1

sourceId

string

extra?

Omit\<SourceSpecification & object, "type" | "data">

Returns

void


ensureLayer()

function ensureLayer(
   map, 
   spec, 
   beforeId?
): void;

Defined in: utils/maplibre.ts:35

Parameters

map

Map$1

spec

LayerSpecification

beforeId?

string

Returns

void


updateSourceFeatures()

function updateSourceFeatures(
   map, 
   sourceId, 
   features
): void;

Defined in: utils/maplibre.ts:44

Parameters

map

Map$1

sourceId

string

features

Feature\<Geometry, GeoJsonProperties>[]

Returns

void


updateSourceWithRecovery()

function updateSourceWithRecovery(
   map, 
   sourceId, 
   features, 
   recreate
): boolean;

Defined in: utils/maplibre.ts:59

Push features to a GeoJSON source, calling recreate once to rebuild the owning layers when the source is missing (initial load, or a style change removed it). Returns false when the source still doesn't exist afterwards.

Parameters

map

Map$1

sourceId

string

features

Feature\<Geometry, GeoJsonProperties>[]

recreate

() => void

Returns

boolean


setLayerVisibility()

function setLayerVisibility(
   map, 
   layerId, 
   visible
): void;

Defined in: utils/maplibre.ts:75

Parameters

map

Map$1

layerId

string

visible

boolean

Returns

void


safeRemoveLayer()

function safeRemoveLayer(map, layerId): void;

Defined in: utils/maplibre.ts:87

Remove a layer if it exists. No-op when missing.

Parameters

map

Map$1

layerId

string

Returns

void


safeRemoveSource()

function safeRemoveSource(map, sourceId): void;

Defined in: utils/maplibre.ts:96

Remove a source if it exists. No-op when missing.

Parameters

map

Map$1

sourceId

string

Returns

void


buildConditionalColorExpr()

function buildConditionalColorExpr(
   normal, 
   selected, 
   conflict?
): ExpressionSpecification;

Defined in: utils/maplibre.ts:109

Build a MapLibre expression of the form: ['case', ['==', ['get','selected'], true], selected, ['==', ['get','in_conflict'], true], conflict, normal] conflict is optional; when omitted the conflict clause is skipped.

Parameters

normal

string

selected

string

conflict?

string

Returns

ExpressionSpecification


buildConditionalImageExpr()

function buildConditionalImageExpr(
   normal, 
   selected, 
   conflict?
): ExpressionSpecification;

Defined in: utils/maplibre.ts:128

Same shape as buildConditionalColorExpr but meant for image / sprite lookups. Kept as a separate function for readability at call sites.

Parameters

normal

string

selected

string

conflict?

string

Returns

ExpressionSpecification


isValidCoordinate()

function isValidCoordinate(lat, lon): boolean;

Defined in: utils/maplibre.ts:136

Parameters

lat

unknown

lon

unknown

Returns

boolean