Class Camera

The Camera class is used to control the camera's position, pitch, bearing, and zoom level. It can also be used to focus on one or more locations on the map. The camera can be repositioned instantly or animated to a new position.

This class is accessed using MapView.Camera

Refer to the Camera Guide for more information and interactive examples.

Accessors

  • get autoMinZoomLevel(): boolean
  • The mode of the camera to automatically set the minimum zoom level based on the size of the scene.

    Returns boolean

  • get bearing(): number
  • The current bearing of the camera in degrees clockwise from North. 0 degrees is North, 90 degrees is East, 180 degrees is South, and 270 degrees is West.

    Returns number

  • get elevation(): number
  • The current elevation of the camera in meters.

    Returns number

  • get maxPitch(): number
  • The maximum pitch of the camera in degrees.

    Returns number

  • get minPitch(): number
  • The minimum pitch of the camera in degrees.

    Returns number

  • get panMode(): "default" | "elevation"
  • The camera's current pan mode.

    Returns "default" | "elevation"

  • get pitch(): number
  • The current pitch of the camera in degrees.

    Returns number

Methods

  • Experimental

    Animate the camera's elevation to a specified elevation.

    Parameters

    • elevation: number

      The target elevation in meters.

    • Optionaloptions: TCameraAnimationOptions

      Optional settings for the camera animation.

    Returns Promise<void>

  • Animates the camera to a specified target.

    Parameters

    Returns Promise<void>

    mapView.Camera.animateTo({ center: coordinate, zoomLevel: 10 }, { duration: 500 });
    
  • Focuses the camera on a specific target or array of targets.

    Parameters

    • target: IFocusable | IFocusable[]

      The target(s) to focus on, either a single element or an array of elements.

    • Optionaloptions: TFocusOnOptions

      Optional settings for focusing the camera.

    Returns Promise<void>

    // Focus on a single space
    mapView.Camera.focusOn(space, { minZoomLevel: 5, duration: 1000 });
  • Get the camera transform that can be used to focus on a target or array of targets. Similar to Camera.focusOn but returns the transform directly.

    Parameters

    Returns TCameraTarget

    The camera transform which can then be passed to Camera.set or Camera.animateTo.

    // Focus on a single space
    const transform = mapView.Camera.getCameraFocusTransform(space, { minZoomLevel: 5 });
    mapView.Camera.animateTo(transform);
  • Sets the camera to a specified target without animation.

    Parameters

    Returns void

    mapView.Camera.set({ center: coordinate, zoomLevel: 10 });
    
  • Toggle the mode of the camera to automatically set the minimum zoom level based on the size of the scene. It will be automatically disabled when the minimum zoom level is set manually.

    Parameters

    • value: boolean

      The new value for the auto min zoom level mode.

    Returns void

  • Experimental

    Set the camera's elevation in meters.

    Parameters

    • elevation: number

      The new elevation in meters.

    Returns void

  • Update the maximum pitch of the camera in degrees.

    Parameters

    • maxPitch: number

      The new maximum pitch.

    Returns void

  • Update the maximum zoom level of the camera in mercator zoom levels.

    Parameters

    • zoomLevel: number

      The new maximum zoom level.

    Returns void

  • Update the minimum pitch of the camera in degrees.

    Parameters

    • minPitch: number

      The new minimum pitch.

    Returns void

  • Experimental

    Set the camera's pan mode. 'elevation' moves the camera up and down, while 'default' allows the camera to pan in all directions.

    Parameters

    • panMode: "default" | "elevation"

      The new pan mode.

    Returns void

  • Define an area of the screen that is safe for the camera. Anything outside the safe area is assumed to be covered in some way. The camera will not place any map elements there when calling Camera.focusOn.

    Parameters

    Returns void

MMNEPVFCICPMFPCPTTAAATR