This is the documentation of version 1.0.0-rc.4. 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 foundations module, with 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 StylingFoundationsModule.setMapColors where one fits.

    Overrides are style edits, not portable settings, so getConfig() leaves them out.

    Only the style's own layers. The layers a data-owned module adds (places, routes, geometries…) take their overrides through that module's layers configuration, and the ones you add are yours.

    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: 'trafficFlow', layerTypes: ['line'] }).setPaint({ 'line-blur': 2 });
    styling.layers.query({ group: 'allPlaceLabels' }).addFilterClause(['within', cityCentre]);
    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. It is empty when the style has no such layers.

      Returns string[]

    • Narrows every matched layer by one more clause, and-ed with the style's own filter, or the one setFilter gave it, and with the filters other modules add. A clause the layer already has is added once.

      Parameters

      • clause: ExpressionFilterSpecification

      Returns this

      MapLibre's within tests points and lines only, so ['within', area] keeps the labels inside an area but drops every polygon, 3D buildings included.

      const majorRoads: ExpressionFilterSpecification = ['in', ['get', 'category'], ['literal', ['motorway', 'trunk']]];
      styling.layers.query({ group: 'roadLabels' }).addFilterClause(majorRoads);
      styling.layers.query({ group: 'roadLabels' }).removeFilterClause(majorRoads);
    • Withdraws a clause addFilterClause added to the matched layers, found by value.

      Parameters

      • clause: ExpressionFilterSpecification

      Returns this

    • Removes every override made through the styling foundations 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, and so do the clauses of addFilterClause.

      Parameters

      • filter: FilterSpecification | undefined

      Returns this

    • Sets layout properties on every matched layer, each a value or a LayerPropertyDerivation as in setPaint. A visibility acts as setVisible.

      Parameters

      • __namedParameters: Omit<LayerPropertyValues<AllLayoutProperties>, "visibility"> & {
            visibility?: "visible" | "none";
        }

      Returns this

    • Shows or hides every matched layer. A layer another module hides stays hidden.

      Parameters

      • visible: boolean

      Returns this