TomTom Maps for JavaScript
    Preparing search index...

    Type Alias LayerPropertyDerivation<VALUE>

    LayerPropertyDerivation: (
        valueUnder: VALUE | undefined,
        layerId: string,
    ) => VALUE

    A paint or layout value worked out per layer from the value beneath it, which is the style's own or the one a knob set. It runs again whenever that value changes, after a style switch or a knob change.

    Type Parameters

    • VALUE

    Type Declaration

      • (valueUnder: VALUE | undefined, layerId: string): VALUE
      • Parameters

        • valueUnder: VALUE | undefined

          The value beneath the override, undefined where the style leaves it unset.

        • layerId: string

          The layer the value is for.

        Returns VALUE

    MapLibre accepts ["zoom"] only as the input of a top-level interpolate or step, so derive a zoom ramp by rewriting each stop's output, not by wrapping the whole ramp.

    // Motorway names in magenta, every other road name in the style's colour or the `label` map colour
    styling.layers.query({ ids: ['TransitLabels - Road'] }).setPaint({
    'text-color': (color) =>
    typeof color === 'string' || Array.isArray(color)
    ? ['case', ['==', ['get', 'category'], 'motorway'], '#c026d3', color]
    : color,
    });