Reference
Layers

Layers

Layers are responsible for rendering data associated with a data source based on a particular style configuration. There are two primary components to a layer: the source that provides the data to render and a layer style that determines how that data gets rendered on a map.

Currently, all layers within MapsGL are TileLayer subclasses.

Layer Types

Layer type values specify how data gets rendered on a map and aren't directly mapped to paint style properties as multiple style properties may be used for a single layer type. For example, a fill layer type will only use the fill style properties, but a circle layer type will use the circle, fill, and stroke style properties. However, all layer types will use the root-level opacity style property to control the layer's overall transparency.

Review our advanced section on layers for more information and examples on setting up and using custom layers.

The following layer types and their respective paint style properties are supported:

raster

Basic raster tile images and textures. Uses raster style properties.

SDK Support
Javascript
>= 1.0.0
Apple
>= 1.0.0
Android
>= 1.0.0-beta.1

fill

Filled and/or stroked vector polygons. Uses fill and stroke style properties.

SDK Support
Javascript
>= 1.0.0
Apple
-
Android
-

line

Stroked vector lines. Uses stroke style properties.

SDK Support
Javascript
>= 1.0.0
Apple
-
Android
-

circle

Filled and/or stroked vector circles. Uses circle, fill, and stroke style properties.

SDK Support
Javascript
>= 1.0.0
Apple
-
Android
-

symbol

SDF (signed distance field) icons, image icons, or quads rendered with custom WebGL shaders. Uses symbol style properties.

SDK Support
Javascript
>= 1.0.0
Apple
-
Android
-

sample

Colorized encoded raster tile data. Uses sample style properties.

SDK Support
Javascript
>= 1.0.0
Apple
>= 1.0.0
Android
>= 1.0.0-beta.1

grid

Symbols rendered on a grid. Uses grid and sample style properties.

SDK Support
Javascript
>= 1.0.0
Apple
-
Android
-

heatmap

Heatmap rendering of point data. Uses heatmap style properties.

SDK Support
Javascript
>= 1.0.0
Apple
-
Android
-

contour

Contour lines from raster data. Uses contour and sample style properties.

SDK Support
Javascript
>= 1.0.0
Apple
-
Android
-

particles

Flow field particles from raster vector data. Uses particle and sample style properties.

SDK Support
Javascript
>= 1.0.0
Apple
>= 1.0.0
Android
-

text

Text labels. Uses text and symbol style properties.

SDK Support
Javascript
>= 1.5.0
Apple
-
Android
-

query

Queries features from another layer using a set of map coordinates and renders that data as text, symbol, or circle features. Uses style properties associated with text, symbol, or circle layer types. Requires a valid value for queryLayer to specify the layer to query features from. Also requires a vector or geojson data source of point features to use as the locations to query.

SDK Support
Javascript
>= 1.5.0
Apple
-
Android
-

composite

Combines multiple layers into a single layer alias. Uses style properties associated with the layer types for each of the layers being combined. When adding composite layers via addWeatherLayer, the return type will always be an array of individual layers associated with the composite layer that were added to the map.

SDK Support
Javascript
>= 1.0.0
Apple
-
Android
-

Layer

The base class for all layers on a map.

Configuration

{
    type: LayerType;
    source: string | SourceSpecification | DataSource;
    sourceLayer?: string;
    sourceType?: SourceType;
    queryLayer?: string | { id: string; hidden?: boolean; };
    queryType?: 'text' | 'symbol' | 'circle';
    mask?: string | { id: string; invert?: boolean; };
    filter?: ExpressionSpecification;
    timeMode?: {
        mode: 'none' | 'any' | 'interval';
        clamp: 'none' | 'past' | 'future' | 'range';
        range?: {
            start: Date;
            end: Date;
        };
        intervals: number;
    };
    timeRange?: TimeRange;
    quality: DataQuality;
    paint: Partial<PaintStyleSpec>;
}

The following configuration options are supported when instantiating Layer instances and subclasses:

OptionDescriptionDefault
typeType: raster | circle | symbol | fill | line | sample | grid | heatmap | contour | particles (required)The type of rendering method to use for the layer. See the list of available layer styles for examples of each type.
sourceType: string (required)The identifier of the data source to be used for the layer.
sourceLayerType: string ()Layer name to use from a vector tile data source that corresponds to the features to render for the layer.
sourceTypeType: point | line | polygon | symbol ()The feature type to use from the sourceLayer when using a vector tile data source.
paintType: PaintStyleSpec (required)Style configuration for the layer. See the list of available layer styles and their properties. Also, review the mapping of layer type values to the supported paint style options for that type.
timeModeType: none | past | future | range | any ()Controls how a time-based layer is rendered relative to the timeline associated with the parent MapController:

- none: layer is not time-specific

- past: layer is only for time intervals in the past

- future: layer is only for time intervals in the future

- range: layer is only for a specified time range as defined by timeRange

- any: layer is time-based but for any time interval
none
timeRangeType: { start: Date; end: Date; } ()For time-based layers, defines the valid time range for the layer when timeMode is set to range.

Properties

The following properties are available on Layer instances and subclasses:

OptionDescriptionDefault
styleType: PaintStyle ()Paint style configuration associated with the layer.
visibleType: boolean (read-only)Whether the layer is currently visible. To change the visibility of a layer, use the show() and hide() methods.true
enabledType: boolean ()Whether the layer is enabled.true
metadataType: Record<string, any> (read-only)Returns metadata information about the layer, such as its identifier, type, source, filters and paint style.
rendererType: LayerRenderer (read-only)Layer style renderer associated with the layer as determined by the layer's configured type.
animatorType: TimeSeriesAnimator (optional)Manages time series data and requests associated with a time-based data source and layer. If the layer is not time-based, then undefined will be returned.
isDirtyType: boolean (read-only)Returns whether the layer has been flagged as dirty, indicating it will be updated during the next rendered frame.false

Methods

Tile Layer

A layer that renders raster, encoded or vector tiles on a map. Extends Layer.

Configuration

// Inherits all configuration options from `Layer`
{
    quality: DataQuality;
}

The following configuration options are supported when instantiating TileLayer instances:

OptionDescriptionDefault
qualityType: exact ()xxxxxxxxxxxx

Properties

The following properties are available on TileLayer instances and subclasses:

OptionDescriptionDefault
qualityType: DataQuality ()Data resolution to use, which controls which data zoom level is requested for a specific map zoom level.

Using a lower data quality value will reduce the amount of data needed for the visible map region but also result is lower data resolution. Using a higher quality value will provide the most accurate result and highest data resolution but also increase the amount of data required.

A lower quality value is useful in environments where resource limitations exist, such as mobile devices or less capable hardware.
exact

Methods