Skip to content

ui/map/navdata/NavaidSnapper

Classes

Defined in: ui/map/navdata/NavaidSnapper.ts:33

NavaidSnapper - shared helper that lets the drawing/creation tools snap a clicked coordinate to the nearest visible navaid (airport, heliport or waypoint).

The navdata is a queryable MapLibre vector source (see NavdataRenderer), so we just probe the rendered point layers in a small pixel box around the cursor and pick the closest hit. queryRenderedFeatures already skips layers whose visibility is 'none', so toggling a navaid type off in Display Options also removes it as a snap target for free.

A single instance is shared by ShapeDrawingManager, RouteDrawingManager and AircraftCreationManager, and also drives a hover highlight (ring + ident label) so the user can see what a click will snap to before committing.

Constructors

Constructor
new NavaidSnapper(
   mapDisplay, 
   stateManager, 
   getMinAirportRank): NavaidSnapper;

Defined in: ui/map/navdata/NavaidSnapper.ts:54

Parameters
mapDisplay

MapDisplay

stateManager

StateManager

getMinAirportRank

(zoom) => number

Returns

NavaidSnapper

Methods

snap()
snap(e): SnapResult | null;

Defined in: ui/map/navdata/NavaidSnapper.ts:73

Find the nearest snappable navaid to the cursor, or null if snapping is off or nothing is within range.

Parameters
e

MapMouseEvent

Returns

SnapResult | null

highlight()
highlight(e): void;

Defined in: ui/map/navdata/NavaidSnapper.ts:129

Update the hover highlight to mark the navaid the cursor would snap to. Shows a ring + ident label when a candidate is found, hides it otherwise.

Parameters
e

MapMouseEvent

Returns

void

clearHighlight()
clearHighlight(): void;

Defined in: ui/map/navdata/NavaidSnapper.ts:150

Hide the highlight (keeps the layers around for the next hover).

Returns

void

teardown()
teardown(): void;

Defined in: ui/map/navdata/NavaidSnapper.ts:160

Remove highlight layers + source entirely.

Returns

void

Interfaces

SnapResult

Defined in: ui/map/navdata/NavaidSnapper.ts:11

Result of a successful snap: the navaid coordinate plus its identity so callers can use the precise position (and, in future, the ICAO/ident name).

Properties

lng
lng: number;

Defined in: ui/map/navdata/NavaidSnapper.ts:12

lat
lat: number;

Defined in: ui/map/navdata/NavaidSnapper.ts:13

ident
ident: string;

Defined in: ui/map/navdata/NavaidSnapper.ts:14

kind
kind: string;

Defined in: ui/map/navdata/NavaidSnapper.ts:15