MapTiler QGIS plugin - supported expressions
MapTiler plugin can convert any style.json containing GL JS style definition. However, the plugin does not support all of the style definition expressions. This article covers which expressions are supported and which are not.
Our cartographers continuously improve MapTiler map styles. Current styles available in MapTiler Cloud are the 2nd generation (version-2). There isstreets-v2
orbasic-v2
. These styles use advanced style expressions in the style.json definition. Unfortunately, some of these expressions are not supported in the QGIS plugin. All the styles that come with the plugin by default are of version-1 and do not use advanced expressions but work OK in the plugin. The older versions of styles are not listed in MapTiler Cloud, however, they can be accessed like this:
Filter expression
Filter expression defines which features will be affected by a specific style layer definition.
Combining filters: all, any, none
Existential filters: has, !has, match, get
Set membership filters: in, !in
Comparison filters: !, ==, !=, >=, >, <=, <
Zoom function
zoom function changes a property of a style layer based on zoom level. Value must be literal values (i.e. not functions or expressions), and appropriate for the property. For example, stop output values for a fill-color
function property must be colors.
{
"base":1,
"stops": [
[zoom1, value1],
[zoom2, value2],
[zoom3, value3]
]
}
Interpolation
[
"interpolate",
[method] // options: ["linear"], ["exponential", base]
["zoom"],
zoom1, value1,
zoom2, value2,
zoom3, value3
]
Cubic-bezier
interpolation is not supported.
Step
[
"step",
input, // e.g. ["get", "attribute"] or ["zoom"]
step_input_0, step_output_0,
stop_input_1, stop_output_1,
stop_input_n, stop_output_n,
...
]
Just one-level nested expressions in the interpolation function are supported. E.g.
"line-color": ["interpolate",
["linear"],
["zoom"],
10, "rgba(138, 195, 229, 1)",
16, [
"match",
["get", "class"],
["river","canal"],
"rgba(160, 205, 236, 1)",
"rgba(140, 185, 226, 1)"
]
]
Paint-properties
Fill
fill-color
Can be defined as a static value (string, hsl, hsla, RGB, rgba), using zoom function or interpolation.
fill-outline-colorCan be defined as a static value (string, hsl, hsla, RGB, rgba), using zoom function or interpolation.
fill-opacityCan be defined as a static value, usingthe zoom function or interpolation.
If opacity is already set in color asan alpha channel, this property is skipped.
fill-translateCan be defined as a static array or usinga zoom function.
fill-patternCan be defined as a string or usinga zoom function
Line
line-colorCan be defined as a static value (string, hsl, hsla, RGB, rgba), using zoom function or interpolation.
line-widthCan be defined as a static value, using zoom function or interpolation.
line-offsetCan be defined as a static value, using zoom function or interpolation.
line-opacityCan be defined as a static value, using zoom function or interpolation.
line-dasharrayCan be defined as a static array or using a zoom function.
line-capCan be round
, square
or flat
(default).
line-joinCan be bevel
, round
or miter
(default).
Labels
text-fieldCan be defined as a static string, expression, list of expression or using zoom function.
text-sizean be defined as a static value, using zoom function or interpolation.
text-max-widthCan be defined as a static value, using zoom function or interpolation.
text-letter-spacingCan be defined as a static value, using zoom function or interpolation.
text-fontCan be defined as a static value (string), list of string or zoom function.
If font not found on your system, the plugin will try to use fallback fonts:
Open Sans Regular
, Arial Unicode MS
text-colorCan be defined as a static value (string, hsl, hsla, RGB, rgba), using zoom function or interpolation.
text-halo-colorCan be defined as a static value (string, hsl, hsla, RGB, rgba), using zoom function or interpolation.
text-halo-widthCan be defined as a static value (string, hsl, hsla, RGB, rgba), using zoom function or interpolation.
text-halo-blurMust be defined as a static value.
text-transformMust be uppercase
or lowercase
.
text-offsetCan be defined as a static array or using zoom function.
text-justifyMust be one of the following: left
, right
, follow
, center
(default).
text-anchorMust be one of the following: center
(default), left
, right
, top
, bottom
, top-left
, top-right
, bottom-left
, bottom-right
.
icon-imageCan be defined as a static string or using zoom function.
Background
background-colorCan be defined as a static value(string, hsl, hsla, RGB, rgba) or zoom function.
background-opacityCan be defined as a static value or zoom function.
Useful links
Vector tile basemaps via QGIS plugin
Mapbox Styles - Expressions
Mapbox Styles - Layers
MapTiler QGIS plugin