Types
#Data type Mapmost SDK for WebGL’s style properties contain various types of values.
##Array
An array is a comma-separated list of one or more numbers in a specific order. For example, used when defining line-dasharray, where the numbers specify the line length and interval. If an array is used as a parameter in an expression, the array must be wrapped in a literal expression.
{
"line-dasharray": [2, 4]
}
{
"circle-color": ["in", 1, ["literal", [1, 2, 3]]]
}
Boolean value (Boolean)
Boolean value means yes or no, so it only accepts true or false values.
{
"fill-enabled": true
}
##Color
Color types are colors in the sRGB color space, with a variety of allowed formats, such as: html-style hexadecimal value, RGB, RGBA, HSL and HSLA. Predefined HTML color names are also allowed, such as yellow and blue.
{
"line-color": "#ff0",
"line-color": "#ffff00",
"line-color": "rgb(255, 255, 0)",
"line-color": "rgba(255, 255, 0, 1)",
"line-color": "hsl(100, 50%, 50%)",
"line-color": "hsla(100, 50%, 50%, 1)",
"line-color": "yellow"
}
Formatted
The formatting type is a string that is divided into parts and annotated with individual formatting options. Format options are listed in the documentation for the format expression.
{
"text-field": ["format",
"foo", { "font-scale": 1.2 },
"bar", { "font-scale": 0.8 }
]
}
##Number Usually an integer or floating point number (decimal number). No quotes required.
{
"text-size": 24
}
Image (ResolvedImage)
The resolvedImage type is an image (such as an icon or pattern) used in a layer.
The input to the image expression operator will be checked against the current map style to see if it can be used for rendering, and will be returned as a resolvedImage type.
The resolvedImage type defines a series of images. If the previous image is not found, the map can return to this series of images. You can wrap the resolvedImage expression in a coalesce expression. If the resolvedImage type does not have a matching image in the style, it will be passed to the image attribute, and the map will throw a styleimagmissing event.
{
"icon-image": ["coalesce", ["image", "myImage"], ["image", "fallbackImage"]]
}
String
String is a text type.
{
"source": "mySource"
}