Configuration
SDK Support | Mapbox GL JS | Android SDK | iOS SDK |
---|---|---|---|
basic functionality | >= 3.0.0 | >= 11.0.0 | >= 11.0.0 |
Schema
A schema describes how a style can be configured. If a schema is present in a style, developers can only change the style through specifying configuration options, and cannot access individual layers. The schema
key is a JSON object with its keys representing the option name, and the value option objects.
*
Specification of a configuration option.
As an example, here’s part of the schema of the Mapbox Standard style:
{
"schema": {
"showPointOfInterestLabels": {
"default": true,
"type": "boolean"
},
"lightPreset": {
"default": "noon",
"values": [ "dawn", "noon", "dusk", "night" ]
}
}
}
Option
An option describes how a particular setting can be configured. The only required key is the default
value, and all other properties are optional. If they are present, the provided configuration value will be checked against the specification, and might be changed to meet the requirements.
default
Default configuration value for this option.
array
If true, this option is returned as an array
maxValue
If this option is a number, this specifies the maximum allowed value. Values higher than this will be clamped to the maximum value.
metadata
Arbitrary properties useful to track with the layer, but do not influence rendering. Properties should be prefixed to avoid collisions, like 'mapbox:'.
minValue
If this option is a number, this specifies the minimum allowed value. Values lower than this will be clamped to the minimum value.
stepValue
If this option is a number, this specifies the increment between allowed values. Values will be rounded towards the nearest allowed value.
type
The type this value is coerced to after evaluating the expression. If unspecified, the result is returned as is and is not validated.
"string"
:The result will be coerced to a string.
"number"
:The result will be coerced to a number.
"boolean"
:The result will be coerced to a boolean.
"color"
:The result will be coerced to a color.
values
If this option is specified, the result must be one of the given values. Otherwise, the default value is used instead.