Skip to main content

data type

Mapmost SDK LiteThe style properties contain various types of values.

color(Color)

Color type issRGBColors in a color space, with a variety of allowed formats, such as:htmlhexadecimal value of styleRGBRGBAHSLandHSLA。 predefinedHTMLColor 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"
}

format(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 }
]
}

image(ResolvedImage)

resolvedImageType is the image used in the layer (such as an icon or pattern). The input to the image expression operator will be checked against the current map style to see if it is available for rendering, and will beresolvedImageType return. resolvedImagetype defines a sequence of images into which the map can return if no previous image is found, you canresolvedImageThe expression is wrapped in acoalescein the expression. ifresolvedImageImages whose type does not match the style will be passed toimageAt this time, the map will throw astyleimagmissingevent.

{
"icon-image": ["coalesce", ["image", "myImage"], ["image", "fallbackImage"]]
}

string(String)

String is a text type.

{
"source": "mySource"
}

boolean (Boolean)

Boolean value means yes or no, so it only acceptstrueorfalsevalue.

{
"fill-enabled": true
}

value (Number)

Usually an integer or floating point number(decimal number)。 No quotes required.

{
"text-size": 24
}

array(Array)

An array is a comma-separated list of one or more numbers in a specific order. For example, in definingline-dasharrayWhen used, the numbers specify the line length and spacing. If an array is used as a parameter in an expression, the array must be wrapped inliteralin the expression.

{
"line-dasharray": [2, 4]
}

{
"circle-color": ["in", 1, ["literal", [1, 2, 3]]]
}