Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface TerrainTileLayerOptions

Configuration options for a TerrainTileLayer.

A TerrainTileLayer is capable of rendering elevation-based 3D terrain using different kinds of input data:

  1. Raster heightmaps: Typically encoded grayscale images or DEM tiles. These are decoded and triangulated client-side into 3D meshes.

  2. Pre-triangulated terrain meshes: Binary or JSON tile formats (e.g., quantized meshes) where the geometry is already prepared and only needs to be rendered.

The layer can optionally render an imagery overlay (such as satellite imagery) on top of the terrain surface.

Hierarchy

Index

Properties

Optional attribution

Attribution information for data sources used by this layer.

Attributions are automatically displayed or hidden depending on whether the corresponding data is currently active or visible on the map — e.g., based on zoom level, layer visibility, or usage. This ensures that only active data providers are credited, as required by licensing.

Can be a simple string (displayed as static text), or an array of structured attribution entries that support clickable labels and optional tooltips.

example

// Simple attribution string attribution: "© Data Provider"

example

// Multiple detailed attributions attribution: [ { label: "© Elevation Provider", url: "https://elevation.example.com", title: "Elevation data source" }, { label: "Imagery © HERE Maps", url: "https://www.here.com", title: "Satellite imagery by HERE" } ]

elevation

elevation: { attribution?: string | DataSourceAttribution | DataSourceAttribution[]; decodeHeight?: (r: number, g: number, b: number, a?: number) => number; decodeMesh?: (data: ArrayBuffer | any, responseType?: string) => TerrainMesh; encoding?: "terrarium" | "mtk" | "xyztrn" | "mapboxrgb" | "custom-raster" | "custom-mesh"; max?: number; min?: number; offset?: number; responseType?: "arraybuffer" | "json" | "blob" | "text" | "image"; scale?: number; url: string | ((z: number, y: number, x: number, quadkey: string) => string) }

Options to configure the remote elevation (DEM) data source.

This layer supports two types of elevation input:

  1. Raster-based heightmaps (e.g. Terrain-RGB or Terrarium tiles)
  2. Precomputed terrain meshes (e.g. via RTIN or quantized meshes)

Raster heightmaps are decoded into elevation values and triangulated into meshes at runtime. Mesh-based sources can directly deliver ready-to-render geometry per tile.

Type declaration

  • Optional attribution?: string | DataSourceAttribution | DataSourceAttribution[]

    Attribution for the elevation data source.

    Can be a string, a single DataSourceAttribution object, or an array of DataSourceAttribution objects. This is used to provide proper credit or licensing information for the elevation tiles.

    see

    TileLayerOptions.attribution

  • Optional decodeHeight?: (r: number, g: number, b: number, a?: number) => number

    Optional function to decode a single elevation value from pixel RGB(A). Only applies to raster heightmap sources. Required for custom raster encodings (if encoding is not set).

    Parameters:

    • r, g, b, a: individual color channels from a tile pixel Returns:
    • Elevation value in meters
      • (r: number, g: number, b: number, a?: number): number
      • Parameters

        • r: number
        • g: number
        • b: number
        • Optional a: number

        Returns number

  • Optional decodeMesh?: (data: ArrayBuffer | any, responseType?: string) => TerrainMesh

    Optional decode function for custom mesh-based elevation tiles. Required for custom mesh encodings (if encoding is not set). This function is expected to parse the raw binary or structured response data (e.g., ArrayBuffer, JSON) into a terrain mesh.

    The responseType must be explicitly set when using decodeMesh to indicate the format of the incoming tile data.

    The returned object must be of type TerrainMesh: { vertices: Float32Array; // flat array of XYZ positions (x0, y0, z0, x1, y1, z1, ...) indices: Uint16Array | Uint32Array; // triangle indices normals?: Float32Array; // optional flat array of vertex normals }

    param

    The raw response body (typically ArrayBuffer or parsed JSON).

    param

    The HTTP response type used when fetching the tile (e.g., "arraybuffer", "json").

    returns

    A TerrainMesh object representing the decoded geometry.

      • (data: ArrayBuffer | any, responseType?: string): TerrainMesh
      • Parameters

        • data: ArrayBuffer | any
        • Optional responseType: string

        Returns TerrainMesh

  • Optional encoding?: "terrarium" | "mtk" | "xyztrn" | "mapboxrgb" | "custom-raster" | "custom-mesh"
  • Optional max?: number

    Maximum zoom level for elevation tile requests. Default is 20.

  • Optional min?: number

    Minimum zoom level for which elevation tiles are available. Default is 1.

  • Optional offset?: number

    Constant offset to apply to decoded elevation values (in meters). Used with scale when no custom decodeHeight or decodeMesh is provided.

  • Optional responseType?: "arraybuffer" | "json" | "blob" | "text" | "image"

    Optional response type hint for custom encodings. Used to determine how the raw tile response is handled before decoding. Required when using decodeMesh to specify the format of the tile response (e.g. 'arraybuffer', 'json').

    This setting allows the decoding pipeline to prepare the expected format from the fetch response.

    Supported values:

    • 'arraybuffer' – fetches raw binary data (recommended for mesh formats or custom binary heightmaps)
    • 'json' – parses response as JSON
    • 'blob' – returns a Blob object (useful for passing to createImageBitmap)
    • 'text' – returns plain text (e.g., CSV or XML)
    • 'image' – returns an HTMLImageElement or ImageBitmap (for direct raster decoding)
  • Optional scale?: number

    Scale factor applied to decoded elevation values (in meters). Used with offset when no custom decodeHeight or decodeMesh is provided.

  • url: string | ((z: number, y: number, x: number, quadkey: string) => string)

    Tile URL template or resolver function for fetching elevation tiles.

    The URL can be a string template (e.g. "https://example.com/tiles/{z}/{x}/{y}.png") or a function that dynamically generates the URL per tile.

    For raster-based elevation data input, the URL points to an image (PNG/WEBP) tiles. For mesh input, the URL should return binary or structured mesh data (e.g. JSON, protobuf).

Optional imagery

imagery: { attribution?: string | DataSourceAttribution | DataSourceAttribution[]; url: string | ((z: number, y: number, x: number, quadkey: string) => string) }

Optional imagery source to be used as a texture overlay on the terrain. This can enhance visual detail by projecting raster tiles (e.g., satellite imagery) over the elevation surface for a more realistic and visually rich 3D map.

Type declaration

  • Optional attribution?: string | DataSourceAttribution | DataSourceAttribution[]

    Attribution for the imagery data source.

    Can be a string, a single DataSourceAttribution object, or an array of such objects. This is used to provide proper credit or licensing information for the imagery tiles, similar to how TileLayerOptions.attribution works.

    see

    TileLayerOptions.attribution

  • url: string | ((z: number, y: number, x: number, quadkey: string) => string)

    Tile URL template or a function returning the tile URL. If a string is provided, it can contain placeholders: {z}, {x}, {y}, or {quadkey}. If a function is provided, it receives the tile coordinates and should return the URL string.

    Examples:

    This is typically used to fetch satellite imagery, orthophotos, or custom raster tiles.

Optional margin

margin: number

tileMargin that should be applied to all providers of the layer.

Optional max

max: number

maximum zoom level at which data from the TileLayer will be displayed.

Optional maxGeometricError

maxGeometricError: number | StyleZoomRange<number>

Controls the mesh simplification accuracy when converting raster heightmaps to terrain meshes.

Specifies the maximum allowed geometric error (in meters) between the original heightmap and the generated mesh.

Can be:

  • a single number (applied globally to all zoom levels), or
  • a zoom-indexed map: { [zoom: number]: number }

This only applies when using raster elevation input.

defaultvalue

{ 0: 5000, 1: 2500, 2: 1300, 3: 700, 4: 400, 5: 200, 6: 100, 7: 50, 8: 25, 9: 12, 10: 6, 11: 3, 12: 1.5, 13: 0.8, 14: 0.4, 15: 0.2, 16: 0.1, 17: 0.05, 18: 0.025, 19: 0.0125, 20: 0.00625 }

Optional min

min: number

minimum zoom level at which data from the TileLayer will be displayed.

Optional name

name: string

Name of the TileLayer.

Optional pointerEvents

pointerEvents: boolean

Whether to enable pointer interactions (e.g. hover/pick)

defaultvalue

false

Optional provider

provider: TileProvider | { max: number; min: number; provider: TileProvider }[]

The data provider(s) for the TileLayer.

The provider can either be a single TileProvider or an array of {min: number, max: number, provider: TileProvider}, where "min" and "max" define the minimum and maximum zoom level at which data from the "provider" should be used. If a single provider is defined, it's data will be used for all zoom levels. If several providers are defined for a single zoom level, only the data of the first defined is used.

Optional style

Optional style configuration for the terrain layer.

Optional tileSize

tileSize: number

the size of the tile data in pixel.

defaultvalue

512

Optional visible

visible: boolean

Indicates whether the layer should be visible (true) or hidden (false).

defaultvalue

true

Generated using TypeDoc