Class Layer<TEvents, TUserData>Abstract

Base class of layers. Layers are components of maps or any compatible entity.

The same layer can be added to multiple entities. Don't forget to call dispose when the layer should be destroyed, as removing a layer from an entity will not release memory associated with the layer (such as textures).

Layers generate textures to be applied to nodes. Nodes might be map tiles, point cloud tiles or any object that matches the definition of the interface.

Layer is an abstract class. See subclasses for specific information. Main subclasses:

  • ColorLayer for color information, such as satellite imagery, vector data, etc.
  • ElevationLayer for elevation and terrain data.
  • MaskLayer: a special kind of layer that applies a mask on its host map.

The userData property can be used to attach custom data to the layer, in a type safe manner. It is recommended to use this property instead of attaching arbitrary properties to the object:

type MyCustomUserData = {
creationDate: Date;
owner: string;
};
const newLayer = new ColorLayer<MyCustomUserData>({ ... });

newLayer.userData.creationDate = Date.now();
newLayer.userData.owner = 'John Doe';

When the source of the layer has a different coordinate system (CRS) than the instance, the images from the source will be reprojected to the instance CRS.

Note that doing so will have a performance cost in both CPU and memory.

// Add and create a new Layer to an existing map.
const newLayer = new ColorLayer({ ... });

await map.addLayer(newLayer);

// Change layer's visibilty
newLayer.visible = false;
instance.notifyChange(); // update instance

// Change layer's opacity
newLayer.opacity = 0.5;
instance.notifyChange(); // update instance

// Listen to properties
newLayer.addEventListener('visible-property-changed', (event) => console.log(event));

Type Parameters

Hierarchy (view full)

Implements

Constructors

Properties

backgroundColor: Color
colorMap: null | ColorMap = null

The colormap of this layer

computeMinMax: boolean
extent: null | Extent = null

The extent of this layer

frozen: boolean = false

Disables automatic updates of this layer. Useful for debugging purposes.

id: string

The unique identifier of this layer.

interpretation: Interpretation
isLayer: boolean = true

Read-only flag to check if a given object is of type Layer.

isMemoryUsage: true = ...

Readonly flag to indicate that his object implements MemoryUsage.

name: undefined | string

Optional name of this layer.

noDataOptions: NoDataOptions
resolutionFactor: number

The resolution factor applied to the textures generated by this layer.

showEmptyTextures: boolean
showTileBorders: boolean

The source of this layer

type: string
userData: TUserData

An object that can be used to store custom data about the Layer.

Accessors

  • get loading(): boolean
  • Gets whether the object is currently performing an asynchronous operation.

    Returns boolean

  • get progress(): number
  • Returns the percentage of progress, in normalized value (i.e in the [0, 1] range), of the asynchronous operations that are scheduled to run on this object. 1 means that all operations have finished.

    Returns number

Methods

  • Adjusts the extent to avoid visual artifacts.

    Parameters

    • originalExtent: Extent

      The original extent.

    • originalWidth: number

      The width, in pixels, of the original extent.

    • originalHeight: number

      The height, in pixels, of the original extent.

    Returns {
        extent: Extent;
        height: number;
        width: number;
    }

    And object containing the adjusted extent, as well as adjusted pixel size.

    • extent: Extent
    • height: number
    • width: number
  • Parameters

    • target: Target

      The target.

    Returns void

  • Parameters

    • texture: TextureAndPitch
    • target: Target
    • isLastRender: boolean

    Returns void

  • Resets all render targets to a blank state and repaint all the targets.

    Parameters

    • Optionalextent: Extent

      An optional extent to limit the region to clear.

    Returns void

  • Parameters

    • extent: Extent

      The extent to test.

    Returns boolean

    true if this layer contains the specified extent, false otherwise.

  • Fire an event type.

    Type Parameters

    • T extends string

    Parameters

    Returns void

  • Returns the final extent of this layer. If this layer has its own extent defined, this will be used. Otherwise, will return the source extent (if any). May return undefined if not pre-processed yet.

    Returns undefined | Extent

    The layer final extent.

  • Called when the layer has finished initializing.

    Returns Promise<void>

  • Updates the provided node with content from this layer.

    Parameters

    Returns void