-
For two inputs, returns the result of subtracting the second input from the first. For a single input, returns the result of subtracting it from 0.
Declaration
Swift
case subtract = "-"
-
Logical negation. Returns
true
if the input isfalse
, andfalse
if the input istrue
.Declaration
Swift
case not = "!"
-
Returns
true
if the input values are not equal,false
otherwise. The comparison is strictly typed: values of different runtime types are always considered unequal. Cases where the types are known to be different at parse time are considered invalid and will produce a parse error. Accepts an optionalcollator
argument to control locale-dependent string comparisons.Declaration
Swift
case neq = "!="
-
Returns the product of the inputs.
Declaration
Swift
case product = "*"
-
Returns the result of floating point division of the first input by the second.
Declaration
Swift
case division = "/"
-
Returns the remainder after integer division of the first input by the second.
Declaration
Swift
case mod = "%"
-
Returns the result of raising the first input to the power specified by the second.
Declaration
Swift
case pow = "^"
-
Returns the sum of the inputs.
Declaration
Swift
case sum = "+"
-
Returns
true
if the first input is strictly less than the second,false
otherwise. The arguments are required to be either both strings or both numbers; if during evaluation they are not, expression evaluation produces an error. Cases where this constraint is known not to hold at parse time are considered in valid and will produce a parse error. Accepts an optionalcollator
argument to control locale-dependent string comparisons.Declaration
Swift
case lt = "<"
-
Returns
true
if the first input is less than or equal to the second,false
otherwise. The arguments are required to be either both strings or both numbers; if during evaluation they are not, expression evaluation produces an error. Cases where this constraint is known not to hold at parse time are considered in valid and will produce a parse error. Accepts an optionalcollator
argument to control locale-dependent string comparisons.Declaration
Swift
case lte = "<="
-
Returns
true
if the input values are equal,false
otherwise. The comparison is strictly typed: values of different runtime types are always considered unequal. Cases where the types are known to be different at parse time are considered invalid and will produce a parse error. Accepts an optionalcollator
argument to control locale-dependent string comparisons.Declaration
Swift
case eq = "=="
-
Returns
true
if the first input is strictly greater than the second,false
otherwise. The arguments are required to be either both strings or both numbers; if during evaluation they are not, expression evaluation produces an error. Cases where this constraint is known not to hold at parse time are considered in valid and will produce a parse error. Accepts an optionalcollator
argument to control locale-dependent string comparisons.Declaration
Swift
case gt = ">"
-
Returns
true
if the first input is greater than or equal to the second,false
otherwise. The arguments are required to be either both strings or both numbers; if during evaluation they are not, expression evaluation produces an error. Cases where this constraint is known not to hold at parse time are considered in valid and will produce a parse error. Accepts an optionalcollator
argument to control locale-dependent string comparisons.Declaration
Swift
case gte = ">="
-
Returns the absolute value of the input.
Declaration
Swift
case abs = "abs"
-
Gets the value of a cluster property accumulated so far. Can only be used in the
clusterProperties
option of a clustered GeoJSON source.Declaration
Swift
case accumulated = "accumulated"
-
Returns the arccosine of the input.
Declaration
Swift
case acos = "acos"
-
Returns
true
if all the inputs aretrue
,false
otherwise. The inputs are evaluated in order, and evaluation is short-circuiting: once an input expression evaluates tofalse
, the result isfalse
and no further input expressions are evaluated.Declaration
Swift
case all = "all"
-
Returns
true
if any of the inputs aretrue
,false
otherwise. The inputs are evaluated in order, and evaluation is short-circuiting: once an input expression evaluates totrue
, the result istrue
and no further input expressions are evaluated.Declaration
Swift
case any = "any"
-
Asserts that the input is an array (optionally with a specific item type and length). If, when the input expression is evaluated, it is not of the asserted type, then this assertion will cause the whole expression to be aborted.
Declaration
Swift
case array = "array"
-
Returns the arcsine of the input.
Declaration
Swift
case asin = "asin"
-
Retrieves an item from an array.
Declaration
Swift
case at = "at"
-
Returns the arctangent of the input.
Declaration
Swift
case atan = "atan"
-
Asserts that the input value is a boolean. If multiple values are provided, each one is evaluated in order until a boolean is obtained. If none of the inputs are booleans, the expression is an error.
Declaration
Swift
case boolean = "boolean"
-
Selects the first output whose corresponding test condition evaluates to true, or the fallback value otherwise.
Declaration
Swift
case switchCase = "case"
-
Returns the smallest integer that is greater than or equal to the input.
Declaration
Swift
case ceil = "ceil"
-
Evaluates each expression in turn until the first non-null value is obtained, and returns that value.
Declaration
Swift
case coalesce = "coalesce"
-
Returns a
collator
for use in locale-dependent comparison operations. Thecase-sensitive
anddiacritic-sensitive
options default tofalse
. Thelocale
argument specifies the IETF language tag of the locale to use. If none is provided, the default locale is used. If the requested locale is not available, thecollator
will use a system-defined fallback locale. Useresolved-locale
to test the results of locale fallback behavior.Declaration
Swift
case collator = "collator"
-
Returns a
string
consisting of the concatenation of the inputs. Each input is converted to a string as if byto-string
.Declaration
Swift
case concat = "concat"
-
Returns the cosine of the input.
Declaration
Swift
case cos = "cos"
-
Returns the shortest distance in meters between the evaluated feature and the input geometry. The input value can be a valid GeoJSON of type
Point
,MultiPoint
,LineString
,MultiLineString
,Polygon
,MultiPolygon
,Feature
, orFeatureCollection
. Distance values returned may vary in precision due to loss in precision from encoding geometries, particularly below zoom level 13.Declaration
Swift
case distance = "distance"
-
Returns the input string converted to lowercase. Follows the Unicode Default Case Conversion algorithm and the locale-insensitive case mappings in the Unicode Character Database.
Declaration
Swift
case downcase = "downcase"
-
Returns the mathematical constant e.
Declaration
Swift
case e = "e"
-
Retrieves a property value from the current feature’s state. Returns null if the requested property is not present on the feature’s state. A feature’s state is not part of the GeoJSON or vector tile data, and must be set programmatically on each feature. Features are identified by their
id
attribute, which must be an integer or a string that can be cast to an integer. Note that [“feature-state”] can only be used with paint properties that support data-driven styling.Declaration
Swift
case featureState = "feature-state"
-
Returns the largest integer that is less than or equal to the input.
Declaration
Swift
case floor = "floor"
-
Returns a
formatted
string for displaying mixed-format text in thetext-field
property. The input may contain a string literal or expression, including an'image'
expression. Strings may be followed by a style override object that supports the following properties:"text-font"
: Overrides the font stack specified by the root layout property."text-color"
: Overrides the color specified by the root paint property."font-scale"
: Applies a scaling factor ontext-size
as specified by the root layout property.
Declaration
Swift
case format = "format"
-
Gets the feature’s geometry type:
Point
,MultiPoint
,LineString
,MultiLineString
,Polygon
,MultiPolygon
.Declaration
Swift
case geometryType = "geometry-type"
-
Retrieves a property value from the current feature’s properties, or from another object if a second argument is provided. Returns null if the requested property is missing.
Declaration
Swift
case get = "get"
-
Tests for the presence of an property value in the current feature’s properties, or from another object if a second argument is provided.
Declaration
Swift
case has = "has"
-
Gets the kernel density estimation of a pixel in a heatmap layer, which is a relative measure of how many data points are crowded around a particular pixel. Can only be used in the
heatmap-color
property.Declaration
Swift
case heatmapDensity = "heatmap-density"
-
Gets the feature’s id, if it has one.
Declaration
Swift
case id = "id"
-
Returns an
image
type for use inicon-image
,*-pattern
entries and as a section in theformat
expression. If set, theimage
argument will check that the requested image exists in the style and will return either the resolved image name ornull
, depending on whether or not the image is currently in the style. This validation process is synchronous and requires the image to have been added to the style before requesting it in theimage
argument.Declaration
Swift
case image = "image"
-
Determines whether an item exists in an array or a substring exists in a string.
Declaration
Swift
case inExpression = "in"
-
Returns the first position at which an item can be found in an array or a substring can be found in a string, or
-1
if the input cannot be found. Accepts an optional index from where to begin the search.Declaration
Swift
case indexOf = "index-of"
-
Produces continuous, smooth results by interpolating between pairs of input and output values (“stops”). The
input
may be any numeric expression (e.g.,["get", "population"]
). Stop inputs must be numeric literals in strictly ascending order. The output type must benumber
,array<number>
, orcolor
.Interpolation types:
["linear"]
: Interpolates linearly between the pair of stops just less than and just greater than the input.["exponential", base]
: Interpolates exponentially between the stops just less than and just greater than the input.base
controls the rate at which the output increases: higher values make the output increase more towards the high end of the range. With values close to 1 the output increases linearly.["cubic-bezier", x1, y1, x2, y2]
: Interpolates using the cubic bezier curve defined by the given control points.
Declaration
Swift
case interpolate = "interpolate"
-
Returns
true
if the input string is expected to render legibly. Returnsfalse
if the input string contains sections that cannot be rendered without potential loss of meaning (e.g. Indic scripts that require complex text shaping, or right-to-left scripts if the themapbox-gl-rtl-text
plugin is not in use in Mapbox GL JS).Declaration
Swift
case isSupportedScript = "is-supported-script"
-
Gets the length of an array or string.
Declaration
Swift
case length = "length"
-
Binds expressions to named variables, which can then be referenced in the result expression using [“var”, “variable_name”].
Declaration
Swift
case letExpression = "let"
-
Gets the progress along a gradient line. Can only be used in the
line-gradient
property.Declaration
Swift
case lineProgress = "line-progress"
-
Provides a literal array or object value.
Declaration
Swift
case literal = "literal"
-
Returns the natural logarithm of the input.
Declaration
Swift
case ln = "ln"
-
Returns mathematical constant ln(2).
Declaration
Swift
case ln2 = "ln2"
-
Returns the base-ten logarithm of the input.
Declaration
Swift
case log10 = "log10"
-
Returns the base-two logarithm of the input.
Declaration
Swift
case log2 = "log2"
-
Selects the output whose label value matches the input value, or the fallback value if no match is found. The input can be any expression (e.g.
["get", "building_type"]
). Each label must be either:- a single literal value; or
- an array of literal values, whose values must be all strings or all numbers (e.g.
[100, 101]
or["c", "b"]
). The input matches if any of the values in the array matches, similar to the"in"
operator. Each label must be unique. If the input type does not match the type of the labels, the result will be the fallback value.
Declaration
Swift
case match = "match"
-
Returns the maximum value of the inputs.
Declaration
Swift
case max = "max"
-
Returns the minimum value of the inputs.
Declaration
Swift
case min = "min"
-
Asserts that the input value is a number. If multiple values are provided, each one is evaluated in order until a number is obtained. If none of the inputs are numbers, the expression is an error.
Declaration
Swift
case number = "number"
-
Converts the input number into a string representation using the providing formatting rules. If set, the
locale
argument specifies the locale to use, as a BCP 47 language tag. If set, thecurrency
argument specifies an ISO 4217 code to use for currency-style formatting. If set, themin
andmax
arguments specify the minimum and maximum number of fractional digits to include.Declaration
Swift
case numberFormat = "number-format"
-
Asserts that the input value is an object. If multiple values are provided, each one is evaluated in order until an object is obtained. If none of the inputs are objects, the expression is an error.
Declaration
Swift
case objectExpression = "object"
-
Returns the mathematical constant pi.
Declaration
Swift
case pi = "pi"
-
Gets the feature properties object. Note that in some cases, it may be more efficient to use [“get”, “property_name”] directly.
Declaration
Swift
case properties = "properties"
-
Returns the IETF language tag of the locale being used by the provided
collator
. This can be used to determine the default system locale, or to determine if a requested locale was successfully loaded.Declaration
Swift
case resolvedLocale = "resolved-locale"
-
Creates a color value from red, green, and blue components, which must range between 0 and 255, and an alpha component of 1. If any component is out of range, the expression is an error.
Declaration
Swift
case rgb = "rgb"
-
Creates a color value from red, green, blue components, which must range between 0 and 255, and an alpha component which must range between 0 and 1. If any component is out of range, the expression is an error.
Declaration
Swift
case rgba = "rgba"
-
Rounds the input to the nearest integer. Halfway values are rounded away from zero. For example,
["round", -1.5]
evaluates to -2.Declaration
Swift
case round = "round"
-
Returns the sine of the input.
Declaration
Swift
case sin = "sin"
-
Gets the distance of a point on the sky from the sun position. Returns 0 at sun position and 1 when the distance reaches
sky-gradient-radius
. Can only be used in thesky-gradient
property.Declaration
Swift
case skyRadialProgress = "sky-radial-progress"
-
Returns an item from an array or a substring from a string from a specified start index, or between a start index and an end index if set. The return value is inclusive of the start index but not of the end index.
Declaration
Swift
case slice = "slice"
-
Returns the square root of the input.
Declaration
Swift
case sqrt = "sqrt"
-
Produces discrete, stepped results by evaluating a piecewise-constant function defined by pairs of input and output values (“stops”). The
input
may be any numeric expression (e.g.,["get", "population"]
). Stop inputs must be numeric literals in strictly ascending order. Returns the output value of the stop just less than the input, or the first output if the input is less than the first stop.Declaration
Swift
case step = "step"
-
Asserts that the input value is a string. If multiple values are provided, each one is evaluated in order until a string is obtained. If none of the inputs are strings, the expression is an error.
Declaration
Swift
case string = "string"
-
Returns the tangent of the input.
Declaration
Swift
case tan = "tan"
-
Converts the input value to a boolean. The result is
false
when then input is an empty string, 0,false
,null
, orNaN
; otherwise it istrue
.Declaration
Swift
case toBoolean = "to-boolean"
-
Converts the input value to a color. If multiple values are provided, each one is evaluated in order until the first successful conversion is obtained. If none of the inputs can be converted, the expression is an error.
Declaration
Swift
case toColor = "to-color"
-
Converts the input value to a number, if possible. If the input is
null
orfalse
, the result is 0. If the input istrue
, the result is 1. If the input is a string, it is converted to a number as specified by the “ToNumber Applied to the String Type” algorithm of the ECMAScript Language Specification. If multiple values are provided, each one is evaluated in order until the first successful conversion is obtained. If none of the inputs can be converted, the expression is an error.Declaration
Swift
case toNumber = "to-number"
-
Returns a four-element array containing the input color’s red, green, blue, and alpha components, in that order.
Declaration
Swift
case toRgba = "to-rgba"
-
Converts the input value to a string. If the input is
null
, the result is""
. If the input is a boolean, the result is"true"
or"false"
. If the input is a number, it is converted to a string as specified by the “NumberToString” algorithm of the ECMAScript Language Specification. If the input is a color, it is converted to a string of the form"rgba(r,g,b,a)"
, wherer
,g
, andb
are numerals ranging from 0 to 255, anda
ranges from 0 to 1. Otherwise, the input is converted to a string in the format specified by theJSON.stringify
function of the ECMAScript Language Specification.Declaration
Swift
case toString = "to-string"
-
Returns a string describing the type of the given value.
Declaration
Swift
case typeofExpression = "typeof"
-
Returns the input string converted to uppercase. Follows the Unicode Default Case Conversion algorithm and the locale-insensitive case mappings in the Unicode Character Database.
Declaration
Swift
case upcase = "upcase"
-
References variable bound using “let”.
Declaration
Swift
case varExpression = "var"
-
Returns
true
if the evaluated feature is fully contained inside a boundary of the input geometry,false
otherwise. The input value can be a valid GeoJSON of typePolygon
,MultiPolygon
,Feature
, orFeatureCollection
. Supported features for evaluation:Point
: Returnsfalse
if a point is on the boundary or falls outside the boundary.LineString
: Returnsfalse
if any part of a line falls outside the boundary, the line intersects the boundary, or a line’s endpoint is on the boundary.
Declaration
Swift
case within = "within"
-
Gets the current zoom level. Note that in style layout and paint properties, [“zoom”] may only appear as the input to a top-level “step” or “interpolate” expression.
Declaration
Swift
case zoom = "zoom"
-
Interpolates linearly between the pair of stops just less than and just greater than the input
Declaration
Swift
case linear = "linear"
-
["exponential", base]
Interpolates exponentially between the stops just less than and just greater than the input. base controls the rate at which the output increases: higher values make the output increase more towards the high end of the range. With values close to 1 the output increases linearly.Declaration
Swift
case exponential = "exponential"
-
["cubic-bezier", x1, y1, x2, y2]
Interpolates using the cubic bezier curve defined by the given control points.Declaration
Swift
case cubicBezier = "cubic-bezier"