Others
Some style properties are no longer the preferred method of achieving specific styling goals. Although they are still supported, they may be removed at a later date, so their use in styles is not recommended and is currently available for reference.
method(Function)
anylayoutorpaintThe values of attributes can be specified as functions. function allows you to base the current map level and/Or a feature’s attributes change the appearance of a map feature.
stops
Required attribute.array(Except for identity functions)。
The set consisting of an input value and an output value is"stop"。 The stop output value must be a literal value (i.e. not a function or expression) and appropriate for this property. For example,fill-colorThe stop output value of the attribute must becolors。
property
Optional attribute.string。
If specifiedproperty,The function will accept the specified feature attributes as input. For more information, see Hierarchy and Property Functions.
base
Optional attribute.number。default value1。
Exponential basis for interpolation curves. It controls the rate at which the function’s output increases. The higher the number, the closer the output is to the top of the range. When the value is close to1, the output increases linearly.
type
Optional attribute.string。"identity","exponential","interval" or "categorical"one of them.
"identity": A function that takes its input and returns it as output.
"exponential": A function that generates an output by interpolating between stops that are slightly smaller or larger than the function input. The field (input value) must be numeric, andstyleProperties must support interpolation. Style properties that support interpolation are marked as"exponential"Sign, exponent are the default function types for these properties.
"interval": a function that returnsstopThe output value is just less than the input value of the function. Field (input value) must be numeric. Any style attribute can use the spacer function. marked as"interval"The symbol’s attribute is the default function type.
"categorical": returnstopA function whose output value is equal to the function input value.
default
The value used as the fallback function result when a value is unavailable. Applicable to the following situations:
- In a classification function, when a feature value does not match any stopping value.
- In the attribute and scale attribute functions, when a property does not contain a value for the specified attribute.
- In the identity function, when the feature value pairsstyleWhen the attribute is invalid(For example, when the function is used on a circle color attribute, however the feature attribute value is not a string or an invalid color)。
- In interval or exponential and scaling functions, when the feature value is not numeric.
If no default value is provided, the style property’s default value is used in these cases.
colorSpace
Optional attribute.string。 "rgb", "lab", "hcl"one of them.
The color space into which the color is inserted. existLABandHCLInserting colors into such a perceptual color space will tend to produce color ramps that appear more consistent, and more consistent than inRGBInserting color into the space makes it easier to distinguish.
"rgb": useRGBcolor space to interpolate color values.
"lab": useLABcolor space to interpolate color values.
"hcl": useHCLcolor space to interpolate color values, interpolating the hue, chroma, and luminance channels separately.
Zoom functions Allows the appearance of map features to change depending on the zoom level of the map. Hierarchy functions can be used to create the illusion of depth and control data density. eachstopis an array containing two elements:The first is the map level and the second is the function output value.
{
"circle-radius": {
"stops": [
// zoom is 5 -> circle radius will be 1px
[5, 1],
// zoom is 10 -> circle radius will be 2px
[10, 2]
]
}
}
Inserts rendered values for color, number, and array properties between stops. Boolean and string property values cannot be interpolated, so their rendered values only change at specified stopping points.
There is an important difference between hierarchical functions rendering layouts and drawing properties. Drawing properties are constantly re-evaluated when the map hierarchy changes, even slightly. The render value of the draw attribute will change, for example, when the map is in the hierarchy4.1and4.6when moving between. However, layout properties are only evaluated once for each integer scaling level. Taking the previous example as an example: the layout properties are presented in4.1and4.6will not change, no matter what stop is specified; but at the zoom level5, the function will be recalculated based on the function, and the property’s rendered value will change. (You can include decimal levels in layout property level functions, which will affect the resulting values; however, rendering will still only change at integer levels.)
Property functionsAllows the appearance of mapped properties to change based on their properties. Attribute functions can be used to visually differentiate between attribute types in the same layer, or to create data visualizations. eachstopis an array containing two elements, the first is the attribute input value, and the second is the function output value. Note that not all properties and platforms support property functions.
{
"circle-color": {
"property": "temperature",
"stops": [
// "temperature" is 0 -> circle color will be blue
[0, 'blue'],
// "temperature" is 100 -> circle color will be red
[100, 'red']
]
}
}
Zoom-and-property functionsAllows the appearance of map features to change with their properties and zoom. eachstopis an array containing two elements, the first is an object with property input values and scaling values, and the second is a function output value. Note that support for attribute functions is not yet complete.
{
"circle-radius": {
"property": "rating",
"stops": [
// zoom is 0 and "rating" is 0 -> circle radius will be 0px
[{zoom: 0, value: 0}, 0],
// zoom is 0 and "rating" is 5 -> circle radius will be 5px
[{zoom: 0, value: 5}, 5],
// zoom is 20 and "rating" is 0 -> circle radius will be 0px
[{zoom: 20, value: 0}, 0],
// zoom is 20 and "rating" is 5 -> circle radius will be 20px
[{zoom: 20, value: 5}, 20]
]
}
}
Other filters (Other filter)
existential judgment
["!has", key]feature[key] does not exist
member judgment
["!in", key, v0, ..., vn] Not included in: feature[key] ∉ { v0 , ..., vn }
Combination judgment
["none", f0, ..., fn] Logically NOR : ¬f0 ∧ ... ∧ ¬fn
_key_Must be a string identifying a feature attribute, or one of the following special keys:
"$type":Function type. This key can be used with"==","! =","in",and"!in"Perform operations. Possible values are"Point"、"LineString"and"Polygon"。"$id":Function identifier. This key can be used with"==","! = ","has","!has","in",and"!in"Perform operations.
a value(andv0, … , vnRepresents a set operator)Must be a string, number, or boolean in order to compare attribute values.
The set membership filter is an intensive and efficient way to test whether a field matches any of multiple values.
Comparison and collection feature filters implement strictly typed comparisons; for example, all values below arefalse: 0 < "1",2 == "2", [true, false]in"true"。
"all"、"any"and"none"Filter operators are used to create compound filters. value f0, … ,fn Must be the filter expression itself.
["==", "$type", "LineString"]
This filter requires each attribute’sclassAttribute equal to"street_major"、"street_minor"or"street_limited"。
["in", "class", "street_major", "street_minor", "street_limited"]`
filter"all"contains the other three filters, whose properties are all required to be true. include:A function must have a class equal to"street_limited",Thatadmin_levelMust be greater than or equal to3,Polygons and their types are not allowed. You can change the combined filter to"any",to allow the inclusion of attributes that match any of these conditions——These properties are polygons, but have different class values, and so on.
[
"all",
["==", "class", "street_limited"],
[">=", "admin_level", 3],
["!in", "$type", "Polygon"]
]