Companion
Functions
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.
Retrieves an item from an array.
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.
Selects the first output whose corresponding test condition evaluates to true, or the fallback value otherwise.
Evaluates each expression in turn until the first non-null value is obtained, and returns that value.
Returns a collator for use in locale-dependent comparison operations. The caseSensitive and diacriticSensitive options default to false. The locale 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, the collator will use a system-defined fallback locale. Use resolvedLocale to test the results of locale fallback behavior.
Returns a formatted string for displaying mixed-format text in the text-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:
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.
Tests for the presence of an property value in the current feature's properties, or from another object if a second argument is provided.
Returns an image type for use in icon-image, *-pattern entries and as a section in the unformatted expression. If set, the image argument will check that the requested image exists in the style and will return either the resolved image name or null, 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 the image argument.
Determines whether an item exists in an array.
Determines whether a substring exists in a string.
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. In a string, a UTF-16 surrogate pair counts as a single position.
Gets the length of an array or string. In a string, a UTF-16 surrogate pair counts as a single position.
Binds expressions to named variables, which can then be referenced in the result expression using var.
Produces a literal array value.
Produces a literal object value.
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:
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.
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, the currency argument specifies an ISO 4217 code to use for currency-style formatting. If set, the min-fraction-digits and max-fraction-digits arguments specify the minimum and maximum number of fractional digits to include.
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.
Returns 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. A UTF-16 surrogate pair counts as a single position.
Returns an item from an list 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.
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.
Converts the input value to a boolean. The result is false when then input is an empty string, 0, false, null, or NaN; otherwise it is true.
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.
Converts the input value to a number, if possible. If the input is null or false, the result is 0. If the input is true, 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.
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)", where r, g, and b are numerals ranging from 0 to 255, and a ranges from 0 to 1. Otherwise, the input is converted to a string in the format specified by the JSON.stringify function of the ECMAScript Language Specification.
Returns a string describing the type of the given value.