SDK JS
    Preparing search index...

    Interface FirstPersonNavController

    The controller returned by createFirstPersonNav.

    const nav = createFirstPersonNav(map);
    const off = nav.on('heightchange', () => console.log(nav.getHeight()));
    nav.enable(); // enter at the camera's current ground position
    nav.setMode('walk'); // block at walls instead of climbing over them
    nav.disable(); // every map handler comes back
    interface FirstPersonNavController {
        enabled: boolean;
        disable(): void;
        dispose(): void;
        enable(): void;
        enterAt(
            lngLat: { lat: number; lng: number },
            entry?: FirstPersonEntry,
        ): void;
        getClampToSurface(): boolean;
        getClimbMax(): number;
        getClimbSlopeDeg(): number;
        getHeight(): number;
        getMode(): FirstPersonNavMode;
        getSpeed(): number;
        on(event: FirstPersonNavEvent, fn: () => void): () => void;
        setClampToSurface(on: boolean): void;
        setClimbMax(m: number): void;
        setHeight(m: number): void;
        setMode(mode: FirstPersonNavMode): void;
        setSpeed(mps: number): void;
    }
    Index

    Properties

    enabled: boolean

    Whether first person is currently active.

    Methods

    • Leave first person and restore every map handler/limit.

      Returns void

    • Disable + release everything. Safe to call repeatedly.

      Returns void

    • Enter first person at the camera's current ground position.

      Returns void

    • Enter first person AT a location (e.g. a pegman drop): the camera glides to eye height above the surface there, then the first-person loop owns it.

      Parameters

      • lngLat: { lat: number; lng: number }
      • Optionalentry: FirstPersonEntry

      Returns void

    • Returns boolean

    • Returns number

    • The steepest slope walk mode will currently climb, DEGREES — the climb allowance resolved against the live speed-scaled probe distance (atan(climbMax / max(2, speed × lookAhead))). Changes when either the climb allowance OR the speed changes; the widget shows it beside the climb slider so the speed coupling is visible instead of silent.

      Returns number

    • Returns number

    • Returns number

    • Lock the eye to the surface (true) or release it into free flight (false) — the fly-mode terrain clamp.

      Locked (the default) the eye rides at getHeight above whatever is rendered under it, gliding up and over relief and rooftops. Unlocked it HOLDS the altitude it had at the moment of the unlock, so flying at a hill flies AT it, not over it; the wheel/height input still raises and lowers the eye (by the same metres it would have added above the surface), and re-locking drops it back to surface + height where it currently stands.

      Walk mode ignores this and always clamps — you cannot walk off the ground. (This is the nav's own clamp. It is NOT maplibre's setCenterClampedToGround, which the nav holds off for the whole session: that flag governs maplibre's per-frame center-elevation follow, which fights the nav's poses at head-level pitches — see enterAt.)

      Parameters

      • on: boolean

        true to pin to the surface, false for free flight.

      Returns void

    • Set the walk-mode climb allowance: the surface rise (m) a forward step may gain across the look-ahead probe before it is refused as a wall. Clamped to ≥ 0 (0 = refuse ANY rise). See FirstPersonNavOptions.climbMaxM for why this is a rise and not a slope.

      Parameters

      • m: number

      Returns void

    • Set the eye height (m above the surface); clamped to ≥ 2 ft.

      Parameters

      • m: number

      Returns void

    • Set the movement speed (m/s); clamped to > 0.

      Parameters

      • mps: number

      Returns void