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

Interface IReadonlyTransform

A variant of ITransform without any mutating functions. Note that an instance of IReadonlyTransform may still be mutated by code that has a reference to in under the ITransform type.

interface IReadonlyTransform {
    applyConstrain: TransformConstrainFunction;
    defaultConstrain: TransformConstrainFunction;
    get autoCalculateNearFarZ(): boolean;
    get bearing(): number;
    get bearingInRadians(): number;
    get cameraPosition(): vec3;
    get cameraToCenterDistance(): number;
    get center(): LngLat;
    get centerOffset(): Point;
    get centerPoint(): Point;
    get clipSpaceToPixelsMatrix(): mat4;
    get constrainOverride(): TransformConstrainFunction;
    get elevation(): number;
    get farZ(): number;
    get fov(): number;
    get fovInRadians(): number;
    get height(): number;
    get inverseProjectionMatrix(): mat4;
    get latRange(): [number, number];
    get lngRange(): [number, number];
    get maxPitch(): number;
    get maxZoom(): number;
    get minElevationForCurrentTile(): number;
    get minPitch(): number;
    get minZoom(): number;
    get modelViewProjectionMatrix(): mat4;
    get nearZ(): number;
    get padding(): PaddingOptions;
    get pitch(): number;
    get pitchInRadians(): number;
    get pixelsPerMeter(): number;
    get pixelsToClipSpaceMatrix(): mat4;
    get pixelsToGLUnits(): [number, number];
    get projectionMatrix(): mat4;
    get renderWorldCopies(): boolean;
    get roll(): number;
    get rollInRadians(): number;
    get rotationMatrix(): mat2;
    get scale(): number;
    get size(): Point;
    get tileSize(): number;
    get tileZoom(): number;
    get unmodified(): boolean;
    get width(): number;
    get worldSize(): number;
    get zoom(): number;
    calculateCameraOptionsFromTo(
        from: LngLatLike,
        altitudeFrom: number,
        to: LngLatLike,
        altitudeTo: number,
    ): CameraOptionsFromTo;
    calculateCenterFromCameraLngLatAlt(
        lngLat: LngLatLike,
        alt: number,
        bearing?: number,
        pitch?: number,
    ): { center: LngLat; elevation: number; zoom: number };
    calculateFogMatrix(unwrappedTileID: UnwrappedTileID): mat4;
    getBounds(): LngLatBounds;
    getCameraAltitude(): number;
    getCameraFrustum(): Frustum;
    getCameraLngLat(): LngLat;
    getCameraPoint(): Point;
    getCameraQueryGeometry(queryGeometry: Point[]): Point[];
    getCircleRadiusCorrection(): number;
    getClippingPlane(): vec4 | null;
    getCoveringTilesDetailsProvider(): CoveringTilesDetailsProvider;
    getFastPathSimpleProjectionMatrix(
        tileID: OverscaledTileID,
    ): mat4 | undefined;
    getMaxBounds(): LngLatBounds | null;
    getPitchedTextCorrection(
        textAnchorX: number,
        textAnchorY: number,
        tileID: UnwrappedTileID,
    ): number;
    getPixelScale(): number;
    getProjectionData(params: ProjectionDataParams): RendererProjectionData;
    getProjectionDataForCustomLayer(
        applyGlobeMatrix: boolean,
    ): CustomLayerProjectionData;
    getRayDirectionFromPixel(p: Point): vec3;
    getVisibleUnwrappedCoordinates(tileID: CanonicalTileID): UnwrappedTileID[];
    isLocationOccluded(
        lngLat: LngLat,
        terrain?: Terrain,
        elevation?: number,
    ): boolean;
    isPaddingEqual(padding: PaddingOptions): boolean;
    isPointOnMapSurface(p: Point, terrain?: Terrain): boolean;
    locationToScreenPoint(lnglat: LngLat, terrain?: Terrain): Point;
    maxPitchScaleFactor(): number;
    projectTileCoordinates(
        x: number,
        y: number,
        unwrappedTileID: UnwrappedTileID,
        elevation?: number,
    ): PointProjection;
    screenPointToLocation(p: Point, terrain?: Terrain): LngLat;
    screenPointToLocationAtElevation(p: Point, elevation: number): LngLat;
    screenPointToMercatorCoordinate(
        p: Point,
        terrain?: Terrain,
    ): MercatorCoordinate;
    screenTerrainPointToMercatorCoordinate(
        p: Point,
        terrain: Terrain,
    ): MercatorCoordinate | null;
    transformLightDirection(dir: vec3): vec3;
}

Hierarchy (View Summary)

Index

Properties

Constrain the center lngLat and zoom to ensure that longitude and latitude bounds are respected and regions beyond the map bounds are not displayed.

defaultConstrain: TransformConstrainFunction

The tranform's default callback that ensures that longitude and latitude bounds are respected by the viewport.

Accessors

  • get autoCalculateNearFarZ(): boolean

    Returns boolean

  • get bearing(): number

    Bearing in degrees.

    Returns number

  • get bearingInRadians(): number

    Returns number

  • get cameraPosition(): vec3

    Returns vec3

    Returns the camera's position transformed to be in the same space as 3D features under this transform's projection. Mostly used for globe + fill-extrusion.

  • get cameraToCenterDistance(): number

    Distance from camera origin to view plane, in pixels. Calculated using vertical fov and viewport height. Center is considered to be in the middle of the viewport.

    Returns number

  • get center(): LngLat

    Returns LngLat

  • get centerPoint(): Point

    The center of the screen in pixels with the top-left corner being (0,0) and +y axis pointing downwards. This accounts for padding.

    Returns Point

  • get clipSpaceToPixelsMatrix(): mat4

    Returns mat4

  • get elevation(): number

    Returns number

  • get farZ(): number

    Returns number

  • get fov(): number

    Vertical field of view in degrees.

    Returns number

  • get fovInRadians(): number

    Returns number

  • get height(): number

    Gets the transform's height in pixels. Use ITransform.resize to set the transform's size.

    Returns number

  • get inverseProjectionMatrix(): mat4

    Inverse of matrix from camera space to clip space.

    Returns mat4

  • get latRange(): [number, number]

    Returns [number, number]

  • get lngRange(): [number, number]

    Returns [number, number]

  • get maxPitch(): number

    Returns number

  • get maxZoom(): number

    Returns number

  • get minElevationForCurrentTile(): number

    Returns number

  • get minPitch(): number

    Returns number

  • get minZoom(): number

    Returns number

  • get modelViewProjectionMatrix(): mat4

    Returns mat4

  • get nearZ(): number

    Returns number

  • get pitch(): number

    Pitch in degrees.

    Returns number

  • get pitchInRadians(): number

    Returns number

  • get pixelsPerMeter(): number

    Returns number

  • get pixelsToClipSpaceMatrix(): mat4

    Returns mat4

  • get pixelsToGLUnits(): [number, number]

    Returns [number, number]

  • get projectionMatrix(): mat4

    Returns mat4

  • get renderWorldCopies(): boolean

    Returns boolean

  • get roll(): number

    Roll in degrees.

    Returns number

  • get rollInRadians(): number

    Returns number

  • get scale(): number

    How many times "larger" the world is compared to zoom 0. Usually computed as pow(2, zoom). Relevant mostly for mercator projection.

    Returns number

  • get size(): Point

    Gets the transform's width and height in pixels (viewport size). Use resize to set the transform's size.

    Returns Point

  • get tileSize(): number

    Returns number

  • get tileZoom(): number

    Returns number

  • get unmodified(): boolean

    Returns boolean

  • get width(): number

    Gets the transform's width in pixels. Use ITransform.resize to set the transform's size.

    Returns number

  • get worldSize(): number

    How many units the current world has. Computed by multiplying worldSize by tileSize. Relevant mostly for mercator projection.

    Returns number

  • get zoom(): number

    Returns number

Methods

  • Given the camera position and the point it looks at, both as lng, lat and altitude above sea level in meters, calculate the center, elevation, zoom, pitch and bearing that place the camera there.

    Parameters

    • from: LngLatLike

      lng, lat of the camera

    • altitudeFrom: number

      altitude of the camera above sea level, in meters

    • to: LngLatLike

      lng, lat of the point the camera looks at, which becomes the center

    • altitudeTo: number

      altitude of that point above sea level, in meters

    Returns CameraOptionsFromTo

    when the camera and the point coincide

  • Given the camera position (lng, lat, alt), calculate the center point and zoom level

    Parameters

    • lngLat: LngLatLike

      lng, lat of the camera

    • alt: number

      altitude of the camera above sea level, in meters

    • Optionalbearing: number

      bearing of the camera, in degrees

    • Optionalpitch: number

      pitch angle of the camera, in degrees

    Returns { center: LngLat; elevation: number; zoom: number }

  • Parameters

    Returns mat4

    Calculate the fogMatrix that, given a tile coordinate, would be used to calculate fog on the map. Currently only supported in mercator projection.

  • Returns LngLatBounds

    Returns a LngLatBounds object describing the map's geographical bounds.

    Returns the map's geographical bounds. When the bearing or pitch is non-zero, the visible region is not an axis-aligned rectangle, and the result is the smallest bounds that encompasses the visible region.

  • The altitude of the camera above the sea level in meters.

    Returns number

  • Returns Frustum

    Return the camera frustum for the current view.

  • The longitude and latitude of the camera.

    Returns LngLat

  • The camera looks at the map from a 3D (lng, lat, altitude) location. Let's use cameraLocation as the name for the location under the camera and on the surface of the earth (lng, lat, 0). cameraPoint is the projected position of the cameraLocation.

    This point is useful to us because only fill-extrusions that are between cameraPoint and the query point on the surface of the earth can extend and intersect the query.

    When the map is not pitched the cameraPoint is equivalent to the center of the map because the camera is right above the center of the map.

    Returns Point

  • When the map is pitched, some of the 3D features that intersect a query will not intersect the query at the surface of the earth. Instead the feature may be closer and only intersect the query because it extrudes into the air.

    Parameters

    • queryGeometry: Point[]

      For point queries, the line from the query point to the "camera point", for other geometries, the envelope of the query geometry and the "camera point"

    Returns Point[]

    a geometry that includes all of the original query as well as all possible ares of the screen where the base of a visible extrusion could be.

  • Returns number

    Allows the projection to adjust the radius of circle-pitch-alignment: 'map' circles and heatmap kernels based on the map's latitude. Circle radius and heatmap kernel radius is multiplied by this value.

  • Returns vec4 | null

    Return the clipping plane, behind which nothing should be rendered. If the camera frustum is sufficient to describe the render geometry (additional clipping is not required), this may be null.

  • Returns a tile-specific projection matrix. Used for symbol placement fast-path for mercator transform.

    Parameters

    Returns mat4 | undefined

  • Returns the maximum geographical bounds the map is constrained to, or null if none set.

    Returns LngLatBounds | null

    max bounds

  • Parameters

    • textAnchorX: number

      Text anchor position inside the tile, X axis.

    • textAnchorY: number

      Text anchor position inside the tile, Y axis.

    • tileID: UnwrappedTileID

      The tile coordinates.

    Returns number

    Allows the projection to adjust the scale of text-pitch-alignment: 'map' symbols's collision boxes based on the map's center and the text anchor. Only affects the collision boxes (and click areas), scaling of the rendered text is mostly handled in shaders.

  • Returns number

  • Return projection data such that coordinates in mercator projection in range 0..1 will get projected to the map correctly.

    Parameters

    • applyGlobeMatrix: boolean

    Returns CustomLayerProjectionData

  • Parameters

    • lngLat: LngLat

      the location

    • Optionalterrain: Terrain

      the terrain that can hide the location; without it only the planet can

    • Optionalelevation: number

      the location's elevation in meters; the terrain's elevation there when omitted, zero without terrain. Marker raises its center with it

    Returns boolean

    true when the planet or the terrain lies between the camera and the location, false when the location is in view. Terrain with no renderable tiles hides nothing.

    Whether the camera cannot see a location. The planet hides it when the location, at its elevation, lies beyond the globe's horizon plane, the plane the globe shaders clip an elevated vertex with. With terrain, the terrain hides it when the ray from the camera to the location meets the rendered terrain surface (see screenTerrainPointToMercatorCoordinate) before it reaches the location, and a location behind the camera or beyond the far plane is hidden too.

  • Returns if the padding params match

    Parameters

    Returns boolean

    true if they are equal, false otherwise

  • Parameters

    • p: Point

      The point's coordinates.

    • Optionalterrain: Terrain

      Optional terrain.

    Returns boolean

    Returns whether the specified screen point lies on the map. May return false if, for example, the point is above the map's horizon, or if doesn't lie on the planet's surface if globe is enabled.

  • Parameters

    Returns Point

    screen point

    Given a LngLat location, return the screen point that corresponds to it.

  • Returns number

  • Parameters

    • x: number
    • y: number
    • unwrappedTileID: UnwrappedTileID
    • Optionalelevation: number

    Returns PointProjection

    Projects a point in tile coordinates to clip space. Used in symbol rendering.

  • Parameters

    • p: Point

      screen point

    • Optionalterrain: Terrain

      optional terrain

    Returns LngLat

    lnglat location

    Given a point on screen, return its LngLat location.

  • Parameters

    • p: Point

      screen point

    • elevation: number

      ground elevation in meters above sea level

    Returns LngLat

    lnglat location

    Given a point on screen, return its LngLat location assuming the ground there lies at the given elevation. When rendering the globe the elevation is ignored.

  • Parameters

    Returns MercatorCoordinate | null

    the hit with z in meters, or null when the terrain has no renderable tiles or the ray never crosses the terrain surface

    Given a point on screen, return the mercator coordinate where its ray hits the rendered terrain surface.

  • Parameters

    • dir: vec3

      The light direction.

    Returns vec3

    A new vector with the transformed light direction.

    Returns light direction transformed to be in the same space as 3D features under this projection. Mostly used for globe + fill-extrusion.

Was this helpful?