Skip to the content.

Operator reference

Every operator this language supports, what it compiles to, and a link to its page on docs.mapbox.com. Anchors were checked against the live page, not guessed.

Arithmetic

Syntax Compiles to Docs
a + b ["+", a, b] +
a - b, -a ["-", a, b], ["-", a] -
a * b ["*", a, b] *
a / b ["/", a, b] /
a % b ["%", a, b] %
a ^ b ["^", a, b] ^

Comparisons

Syntax Compiles to Docs
a == b ["==", a, b] ==
a != b ["!=", a, b] !=
a < b ["<", a, b] <
a <= b ["<=", a, b] <=
a > b [">", a, b] >
a >= b [">=", a, b] >=

Boolean logic

Syntax Compiles to Docs
a and b ["all", a, b] all
a or b ["any", a, b] any
not a ["!", a] !

Lookup

Syntax Compiles to Docs
get("prop") ["get", "prop"] get
has("prop") ["has", "prop"] has
has("prop", object) ["has", "prop", object] has

Variables

Syntax Compiles to Docs
var x = value ["let", "x", value, body] let
x ["var", "x"] var

Control flow

Syntax Compiles to Docs
if ... then ... elif ... else ... ["case", ...] case
match ... then ... else ... ["match", ...] match
coalesce(a, b, ...) ["coalesce", a, b, ...] coalesce

Ramps, scales, curves

Syntax Compiles to Docs
interpolate <type> input ... ["interpolate", ...] interpolate
interpolateHcl <type> input ... ["interpolate-hcl", ...] interpolate-hcl
interpolateLab <type> input ... ["interpolate-lab", ...] interpolate-lab
step input default ... ["step", ...] step

<type> is linear, exponential(base), or cubicBezier(x1, y1, x2, y2).

Math functions

Syntax Docs
abs(x) abs
ceil(x) ceil
floor(x) floor
round(x) round
sqrt(x) sqrt
sin(x), cos(x), tan(x) sin, cos, tan
asin(x), acos(x), atan(x) asin, acos, atan
ln(x), log2(x), log10(x) ln, log2, log10
min(a, b, ...), max(a, b, ...) min, max

String functions

Syntax Docs
concat(a, b, ...) concat
upcase(s) upcase
downcase(s) downcase

Color functions

Syntax Docs
rgb(r, g, b) rgb
rgba(r, g, b, a) rgba

Type conversion

Syntax Compiles to Docs
toNumber(x, ...) ["to-number", x, ...] to-number
toString(x) ["to-string", x] to-string
toBoolean(x) ["to-boolean", x] to-boolean
toColor(x, ...) ["to-color", x, ...] to-color
typeof(x) ["typeof", x] typeof

Constants

Zero-argument operators, grouped by namespace.

Syntax Compiles to Docs
math.e ["e"] e
math.pi ["pi"] pi
math.ln2 ["ln2"] ln2
camera.zoom ["zoom"] zoom
feature.id ["id"] id
feature.geometryType ["geometry-type"] geometry-type
feature.lineProgress ["line-progress"] line-progress
feature.properties ["properties"] properties
feature.accumulated ["accumulated"] accumulated
heatmap.density ["heatmap-density"] heatmap-density

Not yet supported

Mostly the rest of the Lookup family beyond get/has (at, at-interpolated, config, in, index-of, length, measure-light, slice, split, worldview), and the richer Types (array, object, collator, format, image, literal, number-format). distance, feature-state, and within (a Decision operator, not Lookup) take a GeoJSON geometry / a string argument / a GeoJSON geometry respectively, and need their own syntax design rather than fitting the patterns above.

Five documented Mapbox operators are left out on purpose, not by oversight: random, hsl, hsla, pitch, and distance-from-center aren’t supported by this version. Revisit if that changes.