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;
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;
getMatrixForModel(location: LngLatLike, altitude?: number): mat4;
getMaxBounds(): LngLatBounds | null;
getPitchedTextCorrection(
textAnchorX: number,
textAnchorY: number,
tileID: UnwrappedTileID,
): number;
getPixelScale(): number;
getProjectionData(params: ProjectionDataParams): ProjectionData;
getProjectionDataForCustomLayer(applyGlobeMatrix: boolean): ProjectionData;
getRayDirectionFromPixel(p: Point): vec3;
getVisibleUnwrappedCoordinates(tileID: CanonicalTileID): UnwrappedTileID[];
isLocationOccluded(lngLat: LngLat): boolean;
isPaddingEqual(padding: PaddingOptions): boolean;
isPointOnMapSurface(p: Point, terrain?: Terrain): boolean;
lngLatToCameraDepth(lngLat: LngLat, elevation: number): number;
locationToScreenPoint(lnglat: LngLat, terrain?: Terrain): Point;
maxPitchScaleFactor(): number;
projectTileCoordinates(
x: number,
y: number,
unwrappedTileID: UnwrappedTileID,
getElevation: (x: number, y: number) => number,
): PointProjection;
screenPointToLocation(p: Point, terrain?: Terrain): LngLat;
screenPointToMercatorCoordinate(
p: Point,
terrain?: Terrain,
): MercatorCoordinate;
transformLightDirection(dir: vec3): vec3;
}
Hierarchy (View Summary)
- ITransformGetters
- IReadonlyTransform
Index
Properties
Accessors
Methods
Accessors
autoCalculateNearFarZ
- get autoCalculateNearFarZ(): boolean
Returns boolean
bearing
- get bearing(): number
Bearing in degrees.
Returns number
bearingInRadians
- get bearingInRadians(): number
Returns number
cameraPosition
Returns vec3
cameraToCenterDistance
- 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
center
Returns LngLat
centerOffset
Returns Point
centerPoint
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
clipSpaceToPixelsMatrix
Returns mat4
constrainOverride
Returns TransformConstrainFunction
elevation
- get elevation(): number
Returns number
farZ
- get farZ(): number
Returns number
fov
- get fov(): number
Vertical field of view in degrees.
Returns number
fovInRadians
- get fovInRadians(): number
Returns number
height
- get height(): number
Gets the transform's height in pixels. Use ITransform.resize to set the transform's size.
Returns number
inverseProjectionMatrix
Inverse of matrix from camera space to clip space.
Returns mat4
latRange
- get latRange(): [number, number]
Returns [number, number]
lngRange
- get lngRange(): [number, number]
Returns [number, number]
maxPitch
- get maxPitch(): number
Returns number
maxZoom
- get maxZoom(): number
Returns number
minElevationForCurrentTile
- get minElevationForCurrentTile(): number
Returns number
minPitch
- get minPitch(): number
Returns number
minZoom
- get minZoom(): number
Returns number
modelViewProjectionMatrix
Returns mat4
nearZ
- get nearZ(): number
Returns number
padding
Returns PaddingOptions
pitch
- get pitch(): number
Pitch in degrees.
Returns number
pitchInRadians
- get pitchInRadians(): number
Returns number
pixelsPerMeter
- get pixelsPerMeter(): number
pixelsToClipSpaceMatrix
Returns mat4
pixelsToGLUnits
- get pixelsToGLUnits(): [number, number]
Returns [number, number]
projectionMatrix
Returns mat4
renderWorldCopies
- get renderWorldCopies(): boolean
Returns boolean
roll
- get roll(): number
Roll in degrees.
Returns number
rollInRadians
- get rollInRadians(): number
Returns number
rotationMatrix
Returns mat2
scale
- 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
size
Gets the transform's width and height in pixels (viewport size). Use resize to set the transform's size.
Returns Point
tileSize
- get tileSize(): number
Returns number
tileZoom
- get tileZoom(): number
Returns number
unmodified
- get unmodified(): boolean
Returns boolean
width
- get width(): number
Gets the transform's width in pixels. Use ITransform.resize to set the transform's size.
Returns number
worldSize
- get worldSize(): number
zoom
- get zoom(): number
Returns number
Methods
calculateCenterFromCameraLngLatAlt
- calculateCenterFromCameraLngLatAlt(
lngLat: LngLatLike,
alt: number,
bearing?: number,
pitch?: number,
): { center: LngLat; elevation: number; zoom: number }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: numberbearing of the camera, in degrees
Optionalpitch: numberpitch angle of the camera, in degrees
Returns { center: LngLat; elevation: number; zoom: number }
- lngLat: LngLatLike
calculateFogMatrix
Parameters
- unwrappedTileID: UnwrappedTileID
the tile ID
Returns mat4
- unwrappedTileID: UnwrappedTileID
getBounds
Returns LngLatBounds
Returns a LngLatBounds object describing the map's geographical bounds.
getCameraAltitude
The altitude of the camera above the sea level in meters.
Returns number
getCameraFrustum
Returns Frustum
getCameraLngLat
The longitude and latitude of the camera.
Returns LngLat
getCameraPoint
The camera looks at the map from a 3D (lng, lat, altitude) location. Let's use
cameraLocationas the name for the location under the camera and on the surface of the earth (lng, lat, 0).cameraPointis the projected position of thecameraLocation.This point is useful to us because only fill-extrusions that are between
cameraPointand the query point on the surface of the earth can extend and intersect the query.When the map is not pitched the
cameraPointis equivalent to the center of the map because the camera is right above the center of the map.Returns Point
getCameraQueryGeometry
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.
- queryGeometry: Point[]
getCircleRadiusCorrection
getClippingPlane
Returns vec4 | null
getCoveringTilesDetailsProvider
Returns CoveringTilesDetailsProvider
getFastPathSimpleProjectionMatrix
Returns a tile-specific projection matrix. Used for symbol placement fast-path for mercator transform.
Parameters
- tileID: OverscaledTileID
Returns mat4 | undefined
getMatrixForModel
Returns a matrix that will place, rotate and scale a model to display at the given location and altitude while also being projected by the custom layer matrix. This function is intended to be called from custom layers.
Parameters
- location: LngLatLike
Location of the model.
Optionalaltitude: numberAltitude of the model. May be undefined.
Returns mat4
- location: LngLatLike
getMaxBounds
Returns the maximum geographical bounds the map is constrained to, or
nullif none set.Returns LngLatBounds | null
max bounds
getPitchedTextCorrection
- getPitchedTextCorrection(
textAnchorX: number,
textAnchorY: number,
tileID: UnwrappedTileID,
): numberParameters
- 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
- textAnchorX: number
getPixelScale
getProjectionData
Parameters
- params: ProjectionDataParams
Parameters for the projection data generation.
Returns ProjectionData
- params: ProjectionDataParams
getProjectionDataForCustomLayer
Return projection data such that coordinates in mercator projection in range 0..1 will get projected to the map correctly.
Parameters
- applyGlobeMatrix: boolean
Returns ProjectionData
getRayDirectionFromPixel
getVisibleUnwrappedCoordinates
Parameters
- tileID: CanonicalTileID
Returns UnwrappedTileID[]
isLocationOccluded
Parameters
- lngLat: LngLat
Returns boolean
isPaddingEqual
Returns if the padding params match
Parameters
- padding: PaddingOptions
the padding to check against
Returns boolean
true if they are equal, false otherwise
- padding: PaddingOptions
isPointOnMapSurface
Returns boolean
lngLatToCameraDepth
Return the distance to the camera in clip space from a LngLat. This can be compared to the value from the depth buffer (terrain.depthAtPoint) to determine whether a point is occluded.
Parameters
- lngLat: LngLat
the point
- elevation: number
the point's elevation
Returns number
depth value in clip space (between 0 and 1)
- lngLat: LngLat
locationToScreenPoint
maxPitchScaleFactor
Returns number
projectTileCoordinates
- projectTileCoordinates(
x: number,
y: number,
unwrappedTileID: UnwrappedTileID,
getElevation: (x: number, y: number) => number,
): PointProjectionParameters
- x: number
- y: number
- unwrappedTileID: UnwrappedTileID
- getElevation: (x: number, y: number) => number
Returns PointProjection
screenPointToLocation
screenPointToMercatorCoordinate
Returns MercatorCoordinate
lnglat
Constrain the center lngLat and zoom to ensure that longitude and latitude bounds are respected and regions beyond the map bounds are not displayed.