Skip to main content

expression

Anylayoutproperty,paintattribute orfilterThe value of is defined as an expression.

The expression defines the calculation formula for the attribute value. The operators that can be used include:

  • Mathematical operators for arithmetic and other numerical operations
  • Logical operators for Boolean operations and conditional definitions
  • String operators for string operations
  • Data operators that get data source feature attributes
  • Get the camera operator that defines the parameters of the current map view

The expression isJSONArray, the first element is an expression operator, for example"*"or"case",The following elements (if any) are the parameters of the expression. Each argument can be a text value (string, number, boolean, ornull),Can also be another expression array.

[expression_name, argument_0, argument_1, ...]

data expression (Data expressions)​

A data expression is an expression that accesses feature data, that is, any useget、has、id、geometry-type、propertiesorfeature-state expression. Data expressions define the style of features based on their attributes or status, and can be used to distinguish features on the same layer to achieve data visualization.

Data expressions can be used asfilterand mostpaintandlayoutAttribute value, please confirmpaintandlayoutDoes the attribute havedata-driven stylinglogo, additionallyfeature-stateOperator data expressions are only allowed inpaintused on attributes.

{
"circle-color": [
"rgb",
// whenfeature.properties.countThe higher the value, the higher the red value.
["get", "count"],
// green is always zero
0,
// whenfeature.properties.countThe lower the value, the higher the blue value.
["-", 100, ["get", "count"]]
]
}

This example usesgetoperator to get thecountvalue and use that value asrgbThe parameters of the operator define the values ​​​​of red, green, and blue respectively.

camera expression (Camera expressions)​

The camera expression is usingzoomoperator expression. These expressions change the representation style of the layer based on the map zoom level.

{
"circle-radius": [
"interpolate", ["linear"], ["zoom"],
// zoom less than or equal to5 -> The radius of the circle is1px
5, 1,
// zoom Greater than or equal to10 -> The radius of the circle is5px
10, 5
]
}

This example usesinterpolateoperator, taking a set of inputs-The output defines a linear relationship between zoom level and circle size. In this example, the expression means that when the map level is less than or equal to5When , the radius of the circle is1Pixels, when map level is greater than or equal to10When , the radius of the circle should be5pixels, while between the two zoom levels the radius of the circle will be1arrive5Linear interpolation between pixels.

You can use camera expressions wherever expressions can be used. When you use a camera expression aspaintandlayoutattribute value, it must be one of the following forms:

[ "interpolate", interpolation, ["zoom"], ... ]

or:

[ "step", ["zoom"], ... ]

or:

[
"let",
... variable bindings...,
[ "interpolate", interpolation, ["zoom"], ... ]
]

or:

[
"let",
... variable bindings...,
[ "step", ["zoom"], ... ]
]

That is to say, inpaintorlayoutIn the properties,["zoom"]can only be used as an externalinterpolateorstepthe input of an expression, orletexpression within expression.

On-the-fly evaluation of camera expressions,paintandlayoutThere is an important difference between properties:

  • forpaintproperties, when the map hierarchy changes, even a small change,paintThe property’s camera expression will also be re-evaluated. For example, when the map is at the level4.1and4.6When scaling betweenpaintThe property’s camera expression will be constantly re-evaluated.
  • forlayoutProperties, camera expressions are only evaluated at the integer map level. For example, when the map hierarchy changes from4.1change to4.6It will not be recalculated, only when it exceeds5or lower than4will be calculated again.

compound expression (Composition)​

A single expression can mix data operators, camera operators, and other operators. Such compound expressions allow the layer’s style to be determined by combining map-level and individual feature attribute values.

{
"circle-radius": [
"interpolate", ["linear"], ["zoom"],
// whenzoomyes0,Set the circle radius of each feature as an attribute"rating"value
0, ["get", "rating"],
// whenzoomyes10,Set the circle radius of each feature as an attribute"rating"of4times
10, ["*", 4, ["get", "rating"]]
]
}

Expressions that use both data and camera operators are considered both data and camera expressions, and so must adhere to the rules above for both.

type system (Type system)​

The set of types used by the input parameters and result values ​​of expressions include:boolean、string、number、colorand arrays of these types. Furthermore, expressions need to be type-safe: the expression has a known result type and required parameter types,SDKThe expression’s result type is verified to be appropriate for the context in which it is used. For example,filterThe property’s expression result type must beboolean,±The operator parameters must benumber。

generally,SDKThe type of feature attribute values ​​is not known until the feature data is processed. To ensure type safety, when calculating data expressions,SDKThe attribute value will be checked for appropriateness in the context. For example, if you wouldcircle-colorProperty set to expression["get", "feature-color"], SDKEach element will be verifiedfeature-colorWhether the value is a valid color string. If this check fails, it will beSDKOutput an error in a specific manner (usually a log message), using the property’s default value.

In most cases, this verification will occur automatically wherever needed. However, in some cases,SDKThe expected result type of a data expression may not be automatically determined from the surrounding context. For example, it is not clear that the expression["<",["get", "a"], ["get", "b"]]Whether to compare strings or numeric values. In this case, you can use one of the type assertion expression operators to indicate the expected type of the data expression:["<",["number", ["get", "a"]], ["number", ["get", "b"]]。Type assertions check whether the feature data matches the expected type of the data expression. If this check fails, it will output an error and cause the entire expression to return the default value of the defined property. Assertion operators includearray,boolean,numberandstring。

The expression performs only one implicit type conversion: when a color is required, the data expression converts the color expressed as a string into a color value. In all other cases, if you want to convert a type, you must use a type conversion expression operator:to-boolean、to-number、to-stringorto-color。 For example, if you have a feature attribute that stores numeric values ​​in string format, and you want to use the values ​​as numeric values ​​instead of strings, you can use["to-number", ["get", "property-name"]]Such an expression.

If an expression accepts an array argument and the user provides an array literal, the array must be wrapped in anliteralin expression(See example below)。 whenSDKWhen it encounters an array in a style specification attribute value, it assumes the array is an expression and attempts to parse it;SDKThere is no way to distinguish between expressions that fail validation and array literals unless the developer usesliteralOperators make the distinction explicitly. If the array is returned by a subexpression, e.g.["in", 1, ["get", "myArrayProp"]],then no needliteraloperator.

// will throw an error
{
"circle-color": ["in", 1, [1, 2, 3]]
}

// will run as expected
{
"circle-color": ["in", 1, ["literal", [1, 2, 3]]]
}

expression reference (Expression reference)​

Type​

You can use type expressions to test and convert different data types (such as strings, numbers, and Boolean values).

Normally such tests and conversions are unnecessary in type expressions, but they may be necessary in expressions where the types of certain subexpressions are ambiguous. They are also useful in situations where feature data types are inconsistent, for example you can useto-numberto ensure something like"1.5"(instead of1.5)Such values ​​are treated as numeric values.

array​

Assert that the input is an array(Optional, with specific item type and length)。 If, when the input expression is evaluated, it is not of an asserted type, this assertion will cause the entire expression to be aborted.

Grammar rules

["array", value]: array
["array", type: "string" | "number" | "boolean", value]: array<type>
["array",
type: "string" | "number" | "boolean",
N: number (literal),
value
]: array<type, N>

boolean​

Assert that the input value is a Boolean value. If multiple values ​​are provided, they are evaluated sequentially until a Boolean value is obtained. If none of the input values ​​are boolean, the expression is incorrect.

Grammar rules

["boolean", value]: boolean
["boolean", value, fallback: value, fallback: value, ...]: boolean

collator​

Returns a sorter for locale-dependent comparison operations.case-sensitiveanddiacritic-sensitiveThe options default tofalse。 This parameter specifies the locale to useIETFLanguage tag. If not provided, the default language setting is used. If the requested language is not available, the system-defined fallback locale will be used. useresolved-localeSets the result of locale fallback behavior.

Grammar rules

["collator",
{ "case-sensitive": boolean, "diacritic-sensitive": boolean, "locale": string }
]: collator

format​

applied totext-fieldProperty that returns a formatted string for mixed format text. Input can contain a string literal or expression, including a'image'expression. The string can be followed by an overridden style object. The style attributes that support overriding include:

  • "text-font":Covered bylayoutThe font specified by the property.
  • "text-color":Covered bypaintThe color specified by the property.
  • "font-scale":rightlayoutattribute specifiedtext-sizeApply scaling factor.

Grammar rules

["format",
input_1: string | image, options_1: { "font-scale": number, "text-font": array<string>, "text-color": color },
...,
input_n: string | image, options_n: { "font-scale": number, "text-font": array<string>, "text-color": color }
]: formatted

image​

Return aResolvedImage,Available foricon-image、*-patternas well as'format'part of an expression. Includeimageof'coalesce'The expression will evaluate to the first image in the current style. This validation process is synchronous and requires'image'Add the image to the style before requesting it.

Grammar rules

["image", value]: image

literal​

Provides a literal array or object value.

Grammar rules

["literal", [...] (JSON array literal)]: array<T, N>
["literal", [...] (JSON array literal)]: array<T, N>

number​

Assert that the input value is a number. If multiple values ​​are provided, each value is evaluated in turn until a number is obtained. If there are no numbers in the input value, the expression is wrong.

Grammar rules

["number", value]: number
["number", value, fallback: value, fallback: value, ...]: number

number-format​

Converts the entered number to a string representation using the provided formatting rules. If setlocaleThe argument specifies the locale to use and is passed asBCP 47Language tag. If setcurrencyParameter specifies the currency style formatting usedISO 4217code. If setmin-fraction-digitsandmax-fraction-digitsThe parameters specify the minimum and maximum number of fractional digits to include.

Grammar rules

["number-format",
input: number,
options: { "locale": string, "currency": string, "min-fraction-digits": number, "max-fraction-digits": number }
]: string

object​

Assert that the input value is an object. If multiple values ​​are provided, they are evaluated sequentially until an object is obtained. If none of the input values ​​are objects, the expression is wrong.

Grammar rules

["object", value]: object
["object", value, fallback: value, fallback: value, ...]: object

string​

Assert that the input value is a string. If multiple values ​​are provided, each value is evaluated in turn until a string is obtained. If none of the input values ​​are strings, the expression is wrong.

Grammar rules

["string", value]: string
["string", value, fallback: value, fallback: value, ...]: string

to-boolean​

Convert input value to Boolean value. When the input is an empty string,0、false、nullorNaNwhen, the result isfalse,Otherwisetrue。

Grammar rules

["to-boolean", value]: boolean

to-color​

Convert input value to color. If multiple values ​​are provided, each value is evaluated in turn until the first successful conversion is obtained. If none of the input values ​​can be converted, the expression is incorrect.

Grammar rules

["to-color", value, fallback: value, fallback: value, ...]: color

to-number​

Convert input value to number. If the input isnullorfalse,The result is0。If the input istrue,The result is1。If the input is a string, it will be based onECMAScriptThe algorithm in the language specification is converted into the specified numerical value. If multiple values ​​are provided, each value is evaluated in turn until the first successful conversion is obtained. If none of the input values ​​can be converted, the expression is incorrect.

Grammar rules

["to-number", value, fallback: value, fallback: value, ...]: number

to-string​

Convert input value to string. If the input isnull,The result is""。 If the input is a Boolean value, the result is"true"or"false"。If the input is a number, it will be based onECMAScriptThe algorithm in the language specification is converted into the specified string. If the input is a color, it will be converted to"rgba(r,g,b,a)"A string of the form, wherer,g,byes0arrive255number,ayes0arrive1number. If the input is'image'expression,'to-string'Returns the image name. Otherwise, the input will be converted toECMAScriptLinguistically standardizedJSON.stringifyA string in the format specified by the function.

Grammar rules

["to-string", value]: string

typeof​

Returns the type of the given value.

Grammar rules

["typeof", value]: string

feature data​

accumulated​

Returns the value of an aggregate property accumulated so far. Can only be aggregatedGeoJSONsourceclusterPropertiesused in options.

Grammar rules

["accumulated"]: value

feature-state​

Gets the attribute value from the current feature state. Returns if the requested attribute does not belong to the feature statenull。The feature’s status is notGeoJSONor part of the vector tile data, which must be set programmatically on a per-feature basis. elements from itsidattribute identifier,idThe attribute must be an integer or a string convertible to an integer. Notice,["feature-state"]Can only be used to support data-driven stylespaintproperty.

Grammar rules

["feature-state", string]: value

geometry-type​

Returns the geometry type of the feature:Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon。 Multi*Feature types will only appear inGeoJSONIn the data source, when using the vector tile source, there is only a single form.

Grammar rules

["geometry-type"]: string

id​

return attributeid(if any)。

Grammar rules

["id"]: value

line-progress​

Return progress along the gradient line. can only beline-gradientused in properties.

Grammar rules

["line-progress"]: number

properties​

Returns the attribute attribute object. Note that in some cases, directly use["get", "property_name"]Might be more effective.

Grammar rules

["properties"]: object

Find​

at​

Query items from an array.

Grammar rules

["at", number, array]: ItemType

get​

Gets the attribute value from the current feature’s attributes, or from another object if the second parameter is set. Returns if the requested attribute is missingnull。

Grammar rules

["get", string]: value
["get", string, object]: value

has​

Tests for the presence of an attribute value in the current feature’s attributes, or from another object if the second argument is set.

Grammar rules

["has", string]: boolean
["has", string, object]: boolean

in​

Determine whether an item exists in an array, or whether a substring exists in a string. In the specific case where the second and third arguments are string literals, at least one of them must be wrapped inliteralexpression to provide the correct interpretation to the type system.

Grammar rules

["in",
keyword: InputType (boolean, string, or number),
input: InputType (array or string)
]: boolean

index-of​

Returns the first position in an array where the item can be found, or the first position in a string where a substring can be found, or if not found-1。 Accepts an optional index to start searching from anywhere.

Grammar rules

["index-of",
keyword: InputType (boolean, string, or number),
input: InputType (array or string)
]: number
["index-of",
keyword: InputType (boolean, string, or number),
input: InputType (array or string),
index: number
]: number

length​

Returns the length of an array or string.

Grammar rules

["length", string | array | value]: number

slice​

Extracts an item from an array or string, or returns a substring from a string at a specified starting index, or if an ending index is set, returns a substring between the starting and ending indexes. The return value includes the starting index but not the ending index.

Grammar rules

["slice",
input: InputType (array or string),
index: number
]: OutputType (ItemType or string)
["slice",
input: InputType (array or string),
index: number,
index: number
]: OutputType (ItemType or string)

Decision​

You can add conditional logic to your styles using decision expressions. For example,'case'The expression provides"if/then/else"logic, while'match'allows you to map specific values ​​of input expressions to different output expressions.

!

logical negation. If the input isfalsethen returntrue,If the input istruethen returnfalse。

Grammar rules

["!", boolean]: boolean

!=​

Returns if input values ​​are not equaltrue,Otherwise returnfalse。 Strictly typed comparison: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 generate a parse error. accept an optionalcollatorParameters to facilitate control over setting-related string comparisons.

Grammar rules

["!=", value, value]: boolean
["!=", value, value, collator]: boolean

<​

Returns if the first input is strictly less than the second inputtrue,Otherwise returnfalse。 Input values ​​must be two strings or two numbers; Expression evaluation will produce an error if it is not a string or a number during evaluation. Constraints that are known not to exist at parse time are considered valid and will generate a parse error. accept an optionalcollatorParameters to facilitate control over setting-related string comparisons.

Grammar rules

["<", value, value]: boolean
["<", value, value, collator]: boolean

<=​

Returns if the first input is less than or equal to the second inputtrue,Otherwise returnfalse。 Input values ​​must be two strings or two numbers; Expression evaluation will produce an error if it is not a string or a number during evaluation. Constraints that are known not to exist at parse time are considered valid and will generate a parse error. accept an optionalcollatorParameters to facilitate control over setting-related string comparisons.

Grammar rules

["<=", value, value]: boolean
["<=", value, value, collator]: boolean

==​

Returns if input values ​​are equaltrue,Otherwise returnfalse。 Strictly typed comparison: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 generate a parse error. accept an optionalcollatorParameters to facilitate control over setting-related string comparisons.

Grammar rules

["==", value, value]: boolean
["==", value, value, collator]: boolean

>​

Returns if the first input is strictly greater than the second inputtrue,Otherwise returnfalse。 Input values ​​must be two strings or two numbers; Expression evaluation will produce an error if it is not a string or a number during evaluation. Constraints that are known not to exist at parse time are considered valid and will generate a parse error. accept an optionalcollatorParameters to facilitate control over setting-related string comparisons.

Grammar rules

[">", value, value]: boolean
[">", value, value, collator]: boolean

>=​

Returns if the first input is greater than or equal to the second inputtrue,Otherwise returnfalse。 Input values ​​must be two strings or two numbers; Expression evaluation will produce an error if it is not a string or a number during evaluation. Constraints that are known not to exist at parse time are considered valid and will generate a parse error. accept an optionalcollatorParameters to facilitate control over setting-related string comparisons.

Grammar rules

[">=", value, value]: boolean
[">=", value, value, collator]: boolean

all​

If all input conditions aretrue,then returnture,Otherwise return falsefalse。 Evaluated in the order of conditional input, the evaluation is short-circuited: when one of the input expressions evaluates tofalsewhen, the result isfalse,No other input expressions are evaluated again.

Grammar rules

["all", boolean, boolean]: boolean
["all", boolean, boolean, ...]: boolean

any​

If any of the input conditions istrue,then returntrue,Otherwise returnfalse。 Evaluated in the order of conditional input, the evaluation is short-circuited: when one of the input expressions evaluates totruewhen, the result istrue,No other input expressions are evaluated again.

Grammar rules

["any", boolean, boolean]: boolean
["any", boolean, boolean, ...]: boolean

case​

Select the corresponding test condition to evaluate as true the first output, otherwise the fallback value is selected.

Grammar rules

["case",
condition: boolean, output: OutputType,
condition: boolean, output: OutputType,
...,
fallback: OutputType
]: OutputType

coalesce​

Each expression is evaluated in turn until the first valid value is obtained. Invalid value isnulland not available in styles'image'expression. If all values ​​are invalid, thencoalesceReturns the first value listed.

Grammar rules

["coalesce", OutputType, OutputType, ...]: OutputType

match​

Selects the output whose tag value matches the input value, or a fallback value if no match is found. The input value can be any expression (for example,["get", "building_type"])。Each tag must be unique and must be any of the following:

  • single literal;
  • Array of literal values ​​whose values ​​must be all strings or all numbers(For example[100,101]or["c", "b"])。

The input matches if any value in the array uses strict equality matching, something like"in"operator. If the input type does not match the label type, the output result is a fallback value.

Grammar rules

["match",
input: InputType (number or string),
label: InputType | [InputType, InputType, ...], output: OutputType,
label: InputType | [InputType, InputType, ...], output: OutputType,
...,
fallback: OutputType
]: OutputType

within​

Returns if the feature being evaluated is entirely contained within the bounds of the input geometrytrue,Otherwise returnfalse。 The input value can be a validGeoJSON,The type isPolygon、MultiPolygon、FeatureorFeatureCollection。 Supported functions are:

  • Point: Returns if a point is on the boundary or falls outside the boundaryfalse。
  • LineString:Returns if any part of the line falls outside the boundary, or if the line intersects the boundary, or if the endpoint of the line is on the boundaryfalse。

Grammar rules

["within", object]: boolean

Ramps, scales, curves​

interpolate​

By changing the input value and output value("stop")interpolated between to produce continuous, smooth results. The input can be any numeric expression(For example,["get", "population"])。 Stop input values ​​must be strictly ascending numeric literals. The output type must benumber、array<number>orcolor。

Interpolation type:

  • ["linear"]: Linearly interpolates between a pair of dead points just smaller than and just larger than the input.
  • ["exponential", base]: Exponentially interpolates between points smaller and larger than the input. BaseControl the rate at which output grows:The higher the value, the closer the output grows to the high end of the range. When the value is close to1, the output increases linearly.
  • ["cubic-bezier", x1, y1, x2, y2]: Cubic defined using given control pointsbezierThe curve is interpolated.

Grammar rules

["interpolate",
interpolation: ["linear"] | ["exponential", base] | ["cubic-bezier", x1, y1, x2, y2],
input: number,
stop_input_1: number, stop_output_1: OutputType,
stop_input_n: number, stop_output_n: OutputType, ...
]: OutputType (number, array<number>, or Color)

interpolate-hcl​

By pairing the input and output values ​​("stand")Interpolates to produce continuous, smooth results. Works similar to interpolation, but the output type must be color, interpolation is done inHue-Chroma-Luminanceperformed in color space.

Grammar rules

["interpolate-hcl",
interpolation: ["linear"] | ["exponential", base] | ["cubic-bezier", x1, y1, x2, y2],
input: number,
stop_input_1: number, stop_output_1: Color,
stop_input_n: number, stop_output_n: Color, ...
]: Color

interpolate-lab​

By changing the input value and output value("stop")interpolated between to produce continuous, smooth results. picture interpolate Works the same, but the output type must be color and the interpolation is inCIELABperformed in color space.

Grammar rules

["interpolate-lab",
interpolation: ["linear"] | ["exponential", base] | ["cubic-bezier", x1, y1, x2, y2 ],
input: number,
stop_input_1: number, stop_output_1: Color,
stop_input_n: number, stop_output_n: Color, ...
]: Color

step​

By pairing input and output values("stop")Evaluates a defined piecewise constant function, producing a discrete step result. The input can be any numeric expression(For example,["get", "population"])。 Stop input values ​​must be strictly ascending numeric literals. returnstopThe output value is just less than the input value. If the input is less than the firststop,The first output value is returned.

Grammar rules

["step",
input: number,
stop_output_0: OutputType,
stop_input_1: number, stop_output_1: OutputType,
stop_input_n: number, stop_output_n: OutputType, ...
]: OutputType

Variable binding​

let​

Bind an expression to a named variable, which you can then use["var", "variable_name"]Referenced in the result expression.

Grammar rules

["let",
string (alphanumeric literal), any, string (alphanumeric literal), any, ...,
OutputType
]: OutputType

var​

use"let"Reference variable binding.

Grammar rules

["var", previously bound variable name]: the type of the bound expression

String​

concat​

Returns a string consisting of the concatenation of the input values. Each input is converted to a string as if viato-stringSame.

Grammar rules

["concat", value, value, ...]: string

downcase​

Returns the input string converted to lowercase. followUnicodeDefault case conversion algorithm andUnicodeLocale-insensitive case mapping in character database.

Grammar rules

["downcase", string]: string

is-supported-script​

Returns if the expected input string can be rendered clearlytrue。Returns if the input string contains parts that cannot be rendered without loss of meaningfalse(For example, ifMapbox GL JSnot used inmapbox-gl-rtl-textPlug-in requires complex text shapingIndicscript, or right-to-left script).

Grammar rules

["is-supported-script", string]: boolean

resolved-locale​

Returns the culture being used by the provided collatorIETFLanguage tag. This can be used to determine the system’s default language, or to determine whether a requested language was successfully loaded.

Grammar rules

["resolved-locale", collator]: string

upcase​

Returns the input string converted to uppercase. followUnicodeThe default case conversion algorithm andUnicodeCase-insensitive local mapping in the character library.

Grammar rules

["upcase", string]: string

Color​

rgb​

Create red, green, and blue color values ​​that must range between0arrive255between,alphafor1。 If any value is out of range, the expression will error.

Grammar rules

["rgb", number, number, number]: color

rgba​

Create red, green, and blue color values ​​whose range must be within0arrive255between, andalphaThe range must be within0arrive1between. If any value is out of range, the expression will error.

Grammar rules

["rgba", number, number, number]: color

to-rgba​

Returns a red, green, blue, andalphaA four-element array of elements.

Grammar rules

["to-rgba", color]: array<number, 4>

Math​

-​

For two inputs, returns the first input minus the second input. For a single input, return0Subtract the result.

Grammar rules

["-", number, number]: number
["-", number]: number

*​

Returns the product of the inputs.

Grammar rules

["*", number, number, ...]: number

/​

Returns the floating-point division result of the first input divided by the second input.

Grammar rules

["/", number, number]: number

%​

Returns the remainder after the first input is divided by the second input.

Grammar rules

["%", number, number]: number

^​

Returns the specified number (first input) raised to the specified power (second input)

Grammar rules

["^", number, number]: number

+​

Returns the sum of input values

Grammar rules

["+", number, number, ...]: number

abs​

Returns the absolute value of the input.

Grammar rules

["abs", number]: number

acos​

Returns the arc cosine of the input.

Grammar rules

["acos", number]: number

asin​

Returns the arcsine of the input.

Grammar rules

["asin", number]: number

atan​

Returns the arctangent of the input.

Grammar rules

["atan", number]: number

ceil​

Returns the smallest integer greater than or equal to the input.

Grammar rules

["ceil", number]: number

cos​

Returns the cosine of the input.

Grammar rules

["cos", number]: number

distance​

Returns the calculatedfeatureThe shortest distance to the input geometry(in meters)。 The input value can be a validGeoJSON,The type isPoint、MultiPoint、LineString、MultiLineString、Polygon、MultiPolygon、FeatureorFeatureCollection。 Due to the reduced precision of the encoded geometry, the precision of the returned distance values ​​may vary, especially at zoom levels of13the following.

Grammar rules

["distance", object]: number

e​

Returns a mathematical constante。

Grammar rules

["e"]: number

floor​

Returns the largest integer less than or equal to the input.

Grammar rules

["floor", number]: number

ln​

Returns the natural logarithm of the input.

Grammar rules

["ln", number]: number

ln2​

Returns a mathematical constantln(2)。

Grammar rules

["ln2"]: number

log10​

Returns the input with10The base logarithm.

Grammar rules

["log10", number]: number

log2​

Returns the input with2The base logarithm.

Grammar rules

["log2", number]: number

max​

Returns the maximum value of the input.

Grammar rules

["max", number, number, ...]: number

min​

Returns the minimum value of the input.

Grammar rules

["min", number, number, ...]: number

pi​

Returns a mathematical constantpi。

Grammar rules

["pi"]: number

round​

Rounds the input to the nearest integer. Intermediate values ​​are rounded from zero. For example,["round", -1.5]The calculation result is-2。

Grammar rules

["round", number]: number

sin​

Returns the sine value of the input.

Grammar rules

["sin", number]: number

sqrt​

Returns the square root of the input.

Grammar rules

["sqrt", number]: number

tan​

Returns the tangent value of the input.

Grammar rules

["tan", number]: number

Camera​

distance-from-center​

returnsymbolThe distance to the center of the map. Distance is measured in pixels divided by the height of the map container. Its value at the center is0,Decreases when approaching the camera and increases when moving away from the camera. For example, if the height of the map is1000px,value-1Indicates that the distance from the center to the camera is1000px,value1Indicates that the distance from the camera to the center is1000px。 ["distance-from-center"]Can only be used in filter expressions at the symbol level.

Grammar rules

["distance-from-center"]: number

pitch​

Returns the current tilt(in degrees)。 ["pitch"]can only besymbolused in filter expressions.

Grammar rules

["pitch"]: number

zoom​

Returns the current zoom level. Note that in the style layout and drawing properties,["zoom"]Only as a top"step"or"interpolate"expression input

Grammar rules

["zoom"]: number

Heatmap​

heatmap-density​

Returns the kernel density estimate of the pixels in the heat map, which is a relative measure of the number of data points that are crowded around a specific pixel. Can only be used in heatmap color properties.

Grammar rules

["heatmap-density"]: number