For AI agents: a documentation index is available at /llms.txt. Markdown versions of all pages are available by appending .md to any URL.

Class Camera

Methods mixed in to other classes for event capabilities.

Hierarchy (View Summary)

Index

Constructors

Properties

cameraHelper: ICameraHelper
transform: ITransform
transformCameraUpdate: CameraUpdateTransformFunction | null

A callback used to defer camera updates or apply arbitrary constraints. If specified, this Camera instance can be used as a stateless component in React etc.

Methods

  • Returns void

    Applies a change of the terrain under the center to the transform: the terrain was set or removed, or a DEM tile landed. The center keeps its place and the camera moves with the center's elevation, as it does on every rendered frame while nothing holds the elevation. While a gesture or an ease holds it this does nothing: the camera stays where the user put it and the hold's end re-solves zoom and center onto the new terrain without moving it. Nothing is in flight when this writes, so it writes the rendered transform, like the per-frame clamp; a requested camera state created here would outlive the call and the next gesture would start from it.

  • Parameters

    Returns void

    Applies a change that is not itself a movement, such as new bounds, limits or field of view, the way any camera update is applied. A requested camera state created only for this change is dropped again, so a later movement cannot restore the old values.

  • Parameters

    • tr: ITransform

      the requested camera end state If the camera is inside terrain, it gets elevated. Call transformCameraUpdate if present, and then apply the "approved" changes.

    Returns void

    Called after the camera is done being manipulated.

  • Parameters

    • cameraLngLat: LngLatLike
    • cameraAlt: number
    • bearing: number
    • pitch: number
    • Optionalroll: number

    Returns CameraOptions

  • Returns number

  • Returns boolean

  • Returns number

  • Returns number

  • Returns number

  • Returns ITransform

    Transform to apply changes to

    Called when the camera is about to be manipulated. If transformCameraUpdate is specified or terrain is enabled, a copy of the current transform is created to track the accumulated changes. This underlying transform represents the "desired state" proposed by input handlers / animations / UI controls. It may differ from the state used for rendering (this.transform).

  • Returns number

  • Returns number

  • Returns number

  • Returns boolean

  • Returns boolean

  • Returns boolean

  • Returns boolean

  • Returns a true if this instance of Evented or any forwardeed instances of Evented have a listener for the specified type.

    Parameters

    Returns boolean

    true if there is at least one registered listener for specified event type, false otherwise

  • Removes a previously registered event listener.

    Type Parameters

    Parameters

    • type: T

      The event type to remove listeners for.

    • listener: (event: MapEventType[T]) => void

      The listener function to remove.

    Returns this

  • Adds a listener to a specified event type.

    Type Parameters

    Parameters

    • type: T

      The event type to add a listen for.

    • listener: (event: MapEventType[T]) => void

      The function to be called when the event is fired. The listener function is called with the data object passed to fire, extended with target and type properties.

    Returns Subscription

  • Adds a listener that will be called only once to a specified event type.

    The listener will be called first time the event fires after the listener is registered.

    Type Parameters

    Parameters

    • type: T

      The event type to listen for.

    Returns Promise<MapEventType[T]>

    a promise that resolves with the event

  • Adds a listener that will be called only once to a specified event type.

    The listener will be called first time the event fires after the listener is registered.

    Type Parameters

    Parameters

    • type: T

      The event type to listen for.

    • listener: (event: MapEventType[T]) => void

      The function to be called when the event is fired the first time.

    Returns this

    this when a listener is provided

  • Parameters

    • bearing: number
    • Optionaloptions: EaseToOptions
    • OptionaleventData: any

    Returns this

  • Parameters

    • bearing: number
    • OptionaleventData: any

    Returns this

  • Parameters

    • centerClampedToGround: boolean

    Returns void

  • Parameters

    • elevation: number
    • OptionaleventData: any

    Returns this

  • Parameters

    • pitch: number
    • OptionaleventData: any

    Returns this

  • Parameters

    • roll: number
    • OptionaleventData: any

    Returns this

  • Parameters

    Returns void

    Hands the camera the map's terrain, or null when the map has none, and brings the center elevation up to date with it, see Camera.applyTerrainChange.

  • Parameters

    • fov: number
    • OptionaleventData: any

    Returns this

  • Parameters

    • zoom: number
    • OptionaleventData: any

    Returns this

  • Parameters

    • snap: number

    Returns this

  • Parameters

    • OptionalallowGestures: boolean

    Returns this

  • Parameters

    • zoom: number
    • Optionaloptions: EaseToOptions | null
    • OptionaleventData: any

    Returns this

Was this helpful?