On this page

Interface Projection

interface Projection {
    get latitudeErrorCorrectionRadians(): number;
    get name(): | PropertyValueSpecification<ProjectionDefinitionSpecification>
    | undefined;
    get shaderDefine(): string;
    get shaderPreludeCode(): PreparedShader;
    get shaderVariantName(): string;
    get subdivisionGranularity(): SubdivisionGranularitySetting;
    get transitionState(): number;
    get useSubdivision(): boolean;
    get vertexShaderPreludeCode(): string;
    destroy(): void;
    getMeshFromTileID(
        context: Context,
        tileID: CanonicalTileID,
        hasBorder: boolean,
        allowPoles: boolean,
        usage: TileMeshUsage,
    ): Mesh;
    hasTransition(): boolean;
    recalculate(params: EvaluationParameters): void;
    setErrorQueryLatitudeDegrees(value: number): any;
    updateGPUdependent(renderContext: ProjectionGPUContext): void;
}
Index

Accessors

  • get latitudeErrorCorrectionRadians(): number

    Returns number

    Gets the error correction latitude in radians.

  • get shaderDefine(): string

    A #define macro that is injected into every MapLibre shader that uses this projection.

    Returns string

    `const define = projection.shaderDefine; // '#define GLOBE'`
    
  • get shaderVariantName(): string

    Name of the shader projection variant that should be used for this projection. Note that this value may change dynamically, for example when globe projection internally transitions to mercator. Then globe projection might start reporting the mercator shader variant name to make MapLibre use faster mercator shaders.

    Returns string

  • get transitionState(): number

    Returns number

    A number representing the current transition state of the projection. The return value should be a number between 0 and 1, where 0 means the projection is fully in the initial state, and 1 means the projection is fully in the final state.

  • get useSubdivision(): boolean

    Returns boolean

    True if this projection needs to render subdivided geometry. Optimized rendering paths for non-subdivided geometry might be used throughout MapLibre. The value of this property may change during runtime, for example in globe projection depending on zoom.

  • get vertexShaderPreludeCode(): string

    Vertex shader code that is injected into every MapLibre vertex shader that uses this projection.

    Returns string

Methods

  • Returns void

    Cleans up any resources the projection created, especially GPU buffers.

  • Parameters

    • context: Context

      WebGL context.

    • tileID: CanonicalTileID

      The tile coordinates for which to return a mesh. Meshes for tiles that border the top/bottom mercator edge might include extra geometry for the north/south pole.

    • hasBorder: boolean

      When true, the mesh will also include a small border beyond the 0..EXTENT range.

    • allowPoles: boolean

      When true, the mesh will also include geometry to cover the north (south) pole, if the given tileID borders the mercator range's top (bottom) edge.

    • usage: TileMeshUsage

      Specify the usage of the tile mesh, as different usages might use different levels of subdivision.

    Returns Mesh

    Returns a subdivided mesh for a given tile ID, covering 0..EXTENT range.

  • Returns boolean

    Returns true if the projection is currently transitioning between two states.

  • Parameters

    Returns void

    Recalculates the projection state based on the current evaluation parameters.

  • Parameters

    • value: number

    Returns any

    Sets the error query latidude in degrees

  • Parameters

    Returns void

    Runs any GPU-side tasks this projection required. Called at the beginning of every frame.

Was this helpful?
SDK JS
Reference
Projection