This is the documentation of version 0.62.0. Go to the latest version, 1.0.0-rc.5.
TomTom Maps for JavaScript
    Preparing search index...

    Class LayerSelection

    The advanced tier of the styling module: raw MapLibre paint, layout and filter edits over a query of style layers, re-applied across style switches.

    This is the version-coupled tier. Layer ids, expressions and even which layers exist belong to the loaded style version, so an edit may match nothing on the next one: the selection is then empty and the SDK warns once. Prefer a knob or StylingModule.setMapColors where one fits.

    Overrides are not part of getConfig(): they are edits to this style, not portable settings.

    styling.layers.query({ group: 'roadLabels' }).setPaint({ 'text-color': '#93c5fd' });
    styling.layers.query({ metadataGroups: ['water'], layerTypes: ['fill'] }).setPaint({ 'fill-opacity': 0.6 });
    styling.layers.query({ idIncludes: ['railway'] }).setVisible(false);
    styling.layers.query({ group: 'roadLabels' }).reset();
    Index
    query: LayerQuery
    • get layerIds(): string[]

      The ids of the layers the query matches in the loaded style, in draw order. Empty when the style has no such layers.

      Returns string[]

    • Removes every override made through the styling module on the matched layers.

      Returns this

    • Replaces the filter the style gave every matched layer. The filters other modules add, such as POI categories and traffic filters, still narrow it.

      Parameters

      • filter: FilterSpecification | undefined

      Returns this

    • Sets layout properties on every matched layer.

      Parameters

      • layout: Partial<AllLayoutProperties>

      Returns this

    • Sets paint properties on every matched layer.

      Parameters

      • paint: Partial<AllPaintProperties>

      Returns this

    • Shows or hides every matched layer.

      Parameters

      • visible: boolean

      Returns this