Class Layer<TEvents>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).

Types of layers

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.

Reprojection capabilities

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.

Example

// 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

Implements

Constructors

  • Creates a layer.

    Type Parameters

    Parameters

    Returns Layer<TEvents>

Properties

_composer: LayerComposer
_createReadableTextures: boolean
_fallbackImagesPromise: Promise<void>
_filter: Function
_instance: Instance
_opCounter: OperationCounter
_preloadImages: boolean
_preprocessOnce: Promise<Layer<TEvents>>
_queue: RequestQueue
_ready: boolean
_renderTargetPool: Map<string, WebGLRenderTarget<Texture>[]>
_shouldNotify: boolean
_sortedTargets: Target[]
_targets: Map<number, Target>
_visible: boolean
backgroundColor: Color
colorMap: ColorMap

The colormap of this layer

computeMinMax: boolean
disposed: boolean
extent: Extent

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.

name: string

Optional name of this layer.

noDataOptions: NoDataOptions
resolutionFactor: number

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

showTileBorders: boolean
source: ImageSource

The source of this layer

type: string
userData: Record<string, any> = {}

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

  • get ready(): boolean
  • Returns boolean

  • get visible(): boolean
  • Gets or sets the visibility of this layer.

    Returns boolean

    Fires

    Layer#visible-property-changed

  • set visible(v): void
  • Parameters

    • v: boolean

    Returns void

Methods

  • Returns Target[]

    Targets sorted by extent dimension.

  • Parameters

    • width: number

      Width

    • height: number

      Height

    Returns WebGLRenderTarget<Texture>

    The render target.

  • Adds a listener to an event type.

    Type Parameters

    • T extends string

    Parameters

    • type: T

      The type of event to listen to.

    • listener: EventListener<(TEvents & LayerEvents)[T], T, Layer<TEvents>>

      The function that gets called when the event is fired.

    Returns void

  • Type Parameters

    • T extends string

    Parameters

    • type: T
    • listener: EventListener<{}, T, Layer<TEvents>>

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns Extent

  • 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

    • node: Node

    Returns void

  • Parameters

    • texture: TextureAndPitch
    • node: Node
    • isLastRender: boolean

    Returns void

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

    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

    • event: BaseEvent<T> & (TEvents & LayerEvents)[T]

      The event that gets fired.

    Returns void

  • Disposes the layer. This releases all resources held by this layer.

    Returns void

  • Parameters

    • options: {
          extent: Extent;
          height: number;
          target: Target;
          width: number;
      }

      Options.

      • extent: Extent

        The request extent.

      • height: number

        The request height, in pixels.

      • target: Target

        The target of the images.

      • width: number

        The request width, in pixels.

    Returns Promise<void>

    A promise that is settled when all images have been fetched.

  • 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 Extent

    The layer final extent.

  • Parameters

    • target: Target

      The target.

    Returns Target

    The smallest target that still contains this extent.

  • Returns TextureDataType

  • Returns PixelFormat

  • Checks if listener is added to an event type.

    Type Parameters

    • T extends string

    Parameters

    • type: T

      The type of event to listen to.

    • listener: EventListener<(TEvents & LayerEvents)[T], T, Layer<TEvents>>

      The function that gets called when the event is fired.

    Returns boolean

  • Type Parameters

    • T extends string

    Parameters

    • type: T
    • listener: EventListener<{}, T, Layer<TEvents>>

    Returns boolean

  • Perform the initialization. This should be called exactly once in the lifetime of the layer.

    Returns Promise<Layer<TEvents>>

  • Returns Promise<void>

  • Returns Promise<void>

  • Called when the layer has finished initializing.

    Returns Promise<void>

  • Returns void

  • Returns void

  • Processes the target once, fetching all images relevant for this target, then paints those images to the target's texture.

    Parameters

    • target: Target

      The target to paint.

    Returns void

  • Parameters

    Returns void

  • Parameters

    • target: WebGLRenderTarget<Texture>

      The render target to release.

    Returns void

  • Removes a listener from an event type.

    Type Parameters

    • T extends string

    Parameters

    • type: T

      The type of the listener that gets removed.

    • listener: EventListener<(TEvents & LayerEvents)[T], T, Layer<TEvents>>

      The listener function that gets removed.

    Returns void

  • Type Parameters

    • T extends string

    Parameters

    • type: T
    • listener: EventListener<{}, T, Layer<TEvents>>

    Returns void

  • Parameters

    • node: Node

    Returns boolean

  • Removes the node from this layer.

    Parameters

    • node: Node

      The disposed node.

    Returns void

  • Updates the provided node with content from this layer.

    Parameters

    • context: Context

      the context

    • node: Node

      the node to update

    Returns void

  • Parameters

    • material: Material

    Returns void

Generated using TypeDoc