@magiclane/maps-sdk
    Preparing search index...

    Class MapCamera

    Map camera class.

    This class should not be instantiated directly. Instead, use the GemView.camera getter to obtain an instance.

    Controls the map view camera. It lets clients save and restore the camera state, read the current orientation and position, and set position or orientation either directly (quaternion/3D position) or via higher‑level camera transforms (absolute camera placement, target‑centered or target‑relative setups).

    It also provides helpers to compute a camera position and orientation for a given geographic target and heading/pitch/roll or distance parameters, returning a typed position+orientation result together with an operation status.

    Common uses are persisting/ restoring view state, programmatically placing the camera around a point or object, and generating camera matrices for custom actors or animations.

    Index

    Constructors

    • Internal

      Parameters

      • id: number

        The pointer ID

      • mapId: number

        The map ID

      Returns MapCamera

    Accessors

    • set cameraOrientation(pos: Point3d): void

      Sets the camera orientation, with respect to the surface of the focused sphere and current camera position, using heading in degrees (0=N, 90=E, 180=S, 270=W).

      Parameters

      • pos: Point3d

        Point3d representing the desired heading, pitch, and roll.

      Returns void

      An exception if it fails.

    • set cameraPosition(pos: Coordinates): void

      Sets the camera's longitude, latitude position in degrees, with respect to the surface of the focused sphere, altitude in meters above the sphere (sea level), oriented toward the center of the sphere, north up.

      Parameters

      • pos: Coordinates

        Coordinates representing the desired longitude, latitude, and altitude of the camera.

      Returns void

      An exception if it fails.

    • get cameraState(): Uint8Array

      Saves the current state of the camera into a binary format.

      Returns Uint8Array

      The binary representation of the camera's current state.

      An exception if it fails.

    • set cameraState(state: Uint8Array): void

      Restores the camera's state from a previously saved binary format.

      Parameters

      • state: Uint8Array

        The binary representation of the camera's state to restore.

      Returns void

      An exception if it fails.

    • get mapId(): number

      Returns number

    • get orientation(): Point4d

      Retrieves the current orientation of the camera.

      Returns Point4d

      A Point4d representing the current (x, y, z, w) orientation of the camera.

      An exception if it fails.

    • set orientation(orient: Point4d): void

      Sets the camera's orientation using quaternion values.

      Parameters

      • orient: Point4d

        A Point4d representing the new (x, y, z, w) orientation of the camera.

      Returns void

      An exception if it fails.

    • get pointerId(): number

      Returns number

    • get position(): Point3d

      Retrieves the current position of the camera.

      Returns Point3d

      A Point3d representing the current (x, y, z) position of the camera.

      An exception if it fails.

    • set position(pos: Point3d): void

      Sets the camera's position in a 3D space.

      Parameters

      • pos: Point3d

        A Point3d representing the new (x, y, z) position of the camera.

      Returns void

      An exception if it fails.

    Methods

    • Generates a position at longitude, latitude in degrees, with respect to the surface of the focused sphere, altitude in meters above the sphere (sea level), oriented toward the center of the sphere, north up.

      The camera position and orientation are unchanged. The camera or any other object can then be set at the resulting position and with the resulting orientation.

      Parameters

      • targetCoords: Coordinates

        Coordinates representing the desired latitude, longitude and altitude.

      Returns [GemError, PositionOrientation]

      Tuple containing GemError.success on success (otherwise see GemError for other values) and the computed position and orientation.

      An exception if it fails.

    • Generates a position at longitude, latitude in degrees, with respect to the surface of the focused sphere, altitude in meters above the sphere (sea level), oriented toward the specified heading, pitch, and roll.

      The heading is 0 deg=North with respect to the focused sphere, 90 deg=East, 180 deg=South, 270 deg or -90 deg=west.

      Pitch is 0 deg=the object (or camera) forward vector looking toward the center of the focused sphere, 90 deg=looking at horizon.

      Roll is a rotation about the forward vector, positive deg to the left and negative deg to the right.

      The camera position and orientation are unchanged. The camera or any other object can then be set at the resulting position and with the resulting orientation.

      Parameters

      • targetCoords: Coordinates

        Coordinates representing the desired latitude, longitude and altitude.

      • headingPitchRollDeg: Point3d

        Point3d representing the desired heading, pitch and roll.

      Returns [GemError, PositionOrientation]

      Tuple containing GemError.success on success (otherwise see GemError for other values) and the computed position and orientation.

      An exception if it fails.

    • Generates a position and orientation relative to, and oriented toward/centered on, a target position which is relative to the focused sphere (orientation relative to target).

      The target has the specified orientation where heading in degrees (0=N, 90=E, 180=S, 270=W) is with respect to the surface of the focused sphere, pitch in degrees (0=the target forward vector is oriented to the center of the focused sphere, 90=the target forward vector is oriented toward the horizon), and roll in degrees about the target forward vector, positive to the left and negative to the right.

      The generated orientation is toward, and with respect to, the target position, where heading in degrees (0=in the direction of the target heading, 90=looking at the target from its right/starboard side, 180=looking at the target from the front, 270=looking at the target from its left/port side).

      Pitch in degrees (0=looking toward the target center from above the target, 90=looking at the target center from the horizontal plane/equator of the target, which is the plane containing the target forward and right vectors, 180=looking at the target from below). The roll is always 0, so the horizon is level.

      The generated position is at the specified distance in meters from the target center. The camera position and orientation are unchanged. The camera or any other object can then be set at the resulting position and with the resulting orientation.

      Parameters

      • targetCoords: Coordinates

        Coordinates representing the desired latitude, longitude and altitude.

      • targetHeadingPitchRollDeg: Point3d

        Point3d representing the desired heading, pitch and roll.

      • cameraHeadingPitchDegDistanceMeters: Point3d

        Point3d desired heading pitch and distance for camera.

      Returns [GemError, PositionOrientation]

      Tuple containing GemError.success on success (otherwise see GemError for other values) and the computed position and orientation.

      An exception if it fails.

    • Generates a position and orientation relative to a target position, looking in any direction relative to the direction toward the target, all in the coordinate system of the focused target.

      This function is the same as generatePositionAndOrientationRelativeToCenteredTarget, except the orientation can be in a direction other than centered on the target. The orientation is centered on the target when the 4th parameter, the camera/observer heading, pitch, roll = 0, 0, 0. A nonzero heading, in degrees, specifies a rotation about the observer/camera up axis, going through the observer/camera position. A nonzero pitch, in degrees, specifies a rotation about the observer/camera right axis, going through the observer/camera position. A nonzero roll, in degrees, specifies a rotation about the observer/camera forward vector.

      Parameters

      • targetCoords: Coordinates

        Coordinates representing the desired latitude, longitude and altitude.

      • targetHeadingPitchRollDeg: Point3d

        Point3d representing the desired heading, pitch and roll.

      • cameraHeadingPitchDegDistanceMeters: Point3d

        Point3d desired heading pitch and distance for camera.

      • cameraHeadingPitchRollDeg: Point3d

        Point3d desired heading pitch and roll for camera.

      Returns [GemError, PositionOrientation]

      Tuple containing GemError.success on success (otherwise see GemError for other values) and the computed position and orientation.

      An exception if it fails.

    • Generates a position and orientation relative to, and oriented toward/centered on, a target position which is relative to the focused sphere (orientation relative to sphere).

      The specified target position is at lon,lat in degrees, with respect to surface of the focused sphere, altitude in meters above sphere (sea level).

      The target position does not have an orientation, so it can be considered a point.

      The generated orientation is toward the target position, where heading in degrees (0=N, 90=E, 180=S, 270=W) is with respect to the surface of the focused sphere, so heading 0 is looking at the target toward the north, from a position south of the target (the generated position is at 180 degrees as seen from the target).

      Pitch in degrees (0=looking toward the target center from above the target, 90=looking at the target center from the horizontal plane/equator of the target, which is the plane containing the target forward and right vectors). The roll is always 0, so the horizon is level.

      The generated position is at the specified distance in meters from the target center.

      The camera position and orientation are unchanged. The camera or any other object can then be set at the resulting position and with the resulting orientation.

      Parameters

      • targetCoords: Coordinates

        Coordinates representing the desired latitude, longitude and altitude.

      • cameraHeadingPitchDegDistanceMeters: Point3d

        Point3d desired heading pitch and distance for camera.

      Returns [GemError, PositionOrientation]

      Tuple containing GemError.success on success (otherwise see GemError for other values) and the computed position and orientation.

      An exception if it fails.

    • Sets the camera to look toward a target position, all in the coordinate system of the focused target.

      Target coordinates are lon, lat position in degrees, with respect to the focused sphere surface, altitude in meters above the sphere.

      The camera is centered on the target, at the specified distance in meters from the target, heading (0=looking at the target from behind it, in the direction of the target's heading, 90=looking at the target from its right/starboard side, 180=looking at the target from the front, 270=looking at the target from its left/port side) with respect to the focused target, and pitch (0=looking toward the target center from above the target, 90=looking at the target center from the horizontal plane/equator of the target, which is the plane containing the target forward and right vectors, 180=looking at the target from below). The roll is always 0, so the horizon is level.

      Parameters

      • targetCoords: Coordinates

        Coordinates representing the desired latitude, longitude and altitude.

      • targetHeadingPitchRollDeg: Point3d

        Point3d representing the desired heading, pitch and roll.

      • cameraHeadingPitchDegDistanceMeters: Point3d

        Point3d representing the desired heading, pitch and distance.

      Returns void

      An exception if it fails.

    • Sets the camera relative to a target position, looking in any direction relative to the direction toward the target, all in the coordinate system of the focused target.

      This function is the same as setCameraRelativeToCenteredTarget, except the camera can be oriented in a direction other than centered on the target.

      The camera is centered on the target when the 4th parameter, the camera/observer heading, pitch, roll = 0, 0, 0. A nonzero heading, in degrees, specifies a rotation about the observer/camera up axis, going through the observer/camera position. A nonzero pitch, in degrees, specifies a rotation about the observer/camera right axis, going through the observer/camera position. A nonzero roll, in degrees, specifies a rotation about the observer/camera forward vector.

      Parameters

      • targetCoords: Coordinates

        Coordinates representing the desired latitude, longitude and altitude.

      • targetHeadingPitchRollDeg: Point3d

        Point3d representing the desired heading, pitch and roll.

      • cameraHeadingPitchDegDistanceMeters: Point3d

        Point3d representing the desired heading, pitch and distance.

      • cameraHeadingPitchRollDeg: Point3d

        Point3d representing the desired heading, pitch and roll for camera.

      Returns void

      An exception if it fails.

    • Sets the camera to look toward a target position, all in the coordinate system of the focused sphere.

      Target coordinates are longitude, latitude position in degrees, with respect to the focused sphere surface, altitude in meters above the sphere (sea level).

      The camera is centered on the target, at the specified distance in meters from the target, heading (0=N, 90=E, 180=S, 270=W) with respect to the focused sphere, and pitch (0=looking toward the target center from above the target, 90=looking at the target center from the horizontal plane/equator of the target, which is the plane containing the target forward and right vectors). The roll is always 0, so the horizon is level.

      Parameters

      • coords: Coordinates

        Coordinates representing the desired latitude, longitude and altitude.

      • pos: Point3d

        Point3d representing the desired heading, pitch and distance.

      Returns void

      An exception if it fails.