ConstAbsolute value.
Arccosine (result in radians).
Sum of numbers.
Rest...inputs: NumberInput[]True if all inputs are true. Short-circuits on first false.
Rest...inputs: BooleanInput[]True if any input is true. Short-circuits on first true.
Rest...inputs: BooleanInput[]Arcsine (result in radians).
Arctangent (result in radians).
Readonlycase: ((...args: (Resolvable | [BooleanInput, Resolvable])[]) => Expr<ExprValue>)First-match conditional (like if/else-if/else).
Pass [condition, output] tuples followed by a fallback value:
expr.case(
[expr.gt(expr.get("pop"), 1_000_000), "large"],
[expr.gt(expr.get("pop"), 100_000), "medium"],
"small",
)
Rest...args: (Resolvable | [BooleanInput, Resolvable])[]Ceiling (round up).
Return the first non-null value from the given expressions.
Rest...inputs: Resolvable[]Create a collator for locale-aware string comparisons.
Optionaloptions: CollatorOptionsConcatenate values into a string. Non-string values are coerced.
Rest...inputs: Resolvable[]Test whether a value is in an array or a substring is in a string.
Cosine (input in radians).
Cubic bezier interpolation method.
Shortest distance in meters from the evaluated feature to the input geometry.
Division.
Convert a string to lowercase.
Strict equality.
Exponential interpolation method with the given base.
Floor (round down).
Create a formatted text value from one or more text segments with per-segment styling.
Each segment is [text, options?]:
expr.format(
[expr.get("name"), { "font-scale": 1.2, "text-color": "#000" }],
["\n"],
[expr.get("description")],
)
Rest...segments: [StringInput, FormatSegmentOptions?][]Greater than.
Greater than or equal.
Create a color from HSL components (hue 0-360, saturation/lightness 0-100%).
Create a color from HSLA components (hue 0-360, saturation/lightness 0-100%, alpha 0-1).
Resolve an image name from the style's sprite. Usable in icon-image and pattern properties.
Find the first index of a value in an array or substring in a string. Returns -1 if not found.
OptionalfromIndex: NumberInputContinuous interpolation between stops.
expr.interpolate(
expr.linear(),
expr.zoom(),
[0, 0],
[10, 1],
[20, 5],
)
Rest...stops: [number, Resolvable][]Interpolate in the HCL color space. Produces smoother color gradients.
Rest...stops: [number, ColorInput][]Interpolate in the CIELAB color space.
Rest...stops: [number, ColorInput][]True if the evaluated feature intersects the input geometry.
Get the length of an array or string.
Readonlylet: ((bindings: Record<string, Resolvable>, result: Resolvable) => Expr<ExprValue>)Bind variables for use in a result expression.
expr.let({ x: expr.get("population") },
expr.multiply(expr.var("x"), 2),
)
Linear interpolation method.
Natural logarithm.
Readonlyln2: (() => Expr<number>)Base-10 logarithm.
Base-2 logarithm.
Less than.
Less than or equal.
Readonlymatch: ((input: Resolvable, ...casesAndFallback: (Resolvable | [(Resolvable | Resolvable[]), Resolvable])[]) => Expr<ExprValue>)Switch-style matching on an input value.
Pass [label(s), output] tuples followed by a fallback. Labels can be single
values or arrays for multi-match:
expr.match(
expr.get("type"),
["residential", "#0f0"],
[["commercial", "retail"], "#00f"],
"#888",
)
Rest...casesAndFallback: (Resolvable | [(Resolvable | Resolvable[]), Resolvable])[]Maximum of the given numbers.
Rest...inputs: NumberInput[]Minimum of the given numbers.
Rest...inputs: NumberInput[]Modulo (remainder).
Product of numbers.
Rest...inputs: NumberInput[]Strict inequality.
Logical negation.
Format a number using locale-sensitive formatting.
Optionaloptions: NumberFormatOptionsExponentiation: base^exponent.
Get the resolved locale string from a collator.
Create a color from RGB components (0-255).
Create a color from RGBA components (RGB 0-255, alpha 0-1).
Round to nearest integer.
Sine (input in radians).
Extract a subarray or substring. Negative indices count from the end.
Optionalend: NumberInputSquare root.
Piecewise-constant function (staircase). Returns the output value of the stop
whose input value is just less than input.
expr.step(
expr.get("population"),
"#f7fbff", // default (input < first stop)
[10_000, "#6baed6"],
[100_000, "#08306b"],
)
Rest...stops: [number, Resolvable][]Subtraction (two args) or negation (one arg).
Optionalb: NumberInputTangent (input in radians).
Coerce a value to boolean.
Coerce to color, trying each input in order until one succeeds.
Rest...inputs: Resolvable[]Coerce to number, trying each input in order until one succeeds.
Rest...inputs: Resolvable[]Decompose a color into its RGBA components as [r, g, b, a].
ReadonlytoCoerce a value to string.
Get the type of a value as a string ("string", "number", "boolean", "object", "array", "null").
Convert a string to uppercase.
Readonlyvar: ((name: string) => Expr<ExprValue>)True if the evaluated feature is entirely within the input geometry.
Namespace object that groups all expression builder functions.