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

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

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
>= 1.0.0

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;
    timeSeries?: {
        mode: 'none' | 'any' | 'interval';
        clamp: 'none' | 'past' | 'future' | 'range';
        range?: {
            start: Date;
            end: Date;
        };
        intervals: number;
        interleaved: boolean;
    };
    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.
queryLayerType: string | { id: string; hidden?: boolean; } ()The identifier of the layer to query features from when using a query layer type. If the queried layer should be hidden, then set the hidden property to true.
queryTypeType: text | symbol | circle ()The type of feature to render when using a query layer type.
maskType: string | { id: string; invert?: boolean; } ()The identifier of the layer to use as a mask for the layer. If the mask should be inverted, then set the invert property to true.
filterType: ExpressionSpecification ()Filter expression to use for filtering features from the data source. This is only used for vector data sources in GeoJSON or Mapbox Vector Tile (MVT) format. See the documentation on filtering data for more information and examples.
timeSeries.modeType: none | any | interval ()Controls how a time-based layer is rendered relative to the timeline associated with the parent MapController:

- none: layer is not time-specific and should be displayed at any time

- any: layer is time-specific but can be displayed at any time

- interval: layer is time-specific and should be displayed at valid time intervals as defined by the data source
none
timeSeries.clampType: none | past | future | range ()Defines how to restrict the visibility of a time-specific layer:

- none: layer can be displayed at any time

- past: layer can only be displayed for past time intervals

- future: layer can only be displayed for future time intervals

- range: layer can only be displayed within a specific time range as defined by timeSeries.range
none
timeSeries.rangeType: { start: Date; end: Date; } ()For time-based layers, defines the valid start and end date range for the layer. When provided, the layer will automatically be hidden outside of this date range.
timeSeries.intervalsType: number ()Maximum number of time intervals to use for the data set.``
timeSeries.interleavedType: boolean ()Whether data requests for the layer's animation intervals should be interleaved.true
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.

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