Atlaslog
Atlaslog / MapLibre GL JS / API reference / Style Expression
MapLibre GL JS · API reference

Style Expression

Quick answer

A style expression is an array-form mini language: the first element names the operator and the remaining elements are arguments, evaluated per feature or per camera. Use interpolate with zoom for scale-dependent values, and get for feature-driven properties. Expressions replace the deprecated function objects in paint and layout.

Last verified 2026-11-03 · MapLibre GL JS 4.x · Cite this page
['interpolate', ['linear'], ['zoom'], 4 , 1, 10 , 6]
Key points
Example
/* 按属性分类着色,未命中的走默认色 */
map.setPaintProperty('world-fill', 'fill-color', [
  'match', ['get', 'CONTINENT'],
  'Asia', '#dbe7f3',
  'Europe', '#e6e0f3',
  'Africa', '#f3ecdb',
  '#e9ecef'
]);

/* 线宽随缩放连续变化 */
map.setPaintProperty('world-line', 'line-width', [
  'interpolate', ['linear'], ['zoom'],
  2, 0.5,
  6, 2,
  10, 5
]);

/* 数值分段,避免连续插值造成图标忽大忽小 */
map.setPaintProperty('city-dot', 'circle-radius', [
  'step', ['to-number', ['get', 'pop']],
  3,
  1000000, 6
]);

/* 缺属性时的兜底 */
map.setLayoutProperty('city-label', 'text-field', [
  'coalesce', ['get', 'NAME'], ['get', 'name'], '未命名'
]);
Notes
Runnable examplesChinese originalAll API references
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Cite this page

Atlaslog (2026). Style Expression. https://www.jingweizhi.com/en/maplibre/api/style-expression.html (accessed 2026-11-03).