Atlaslog
Atlaslog / MapLibre GL JS / API reference / Layer
MapLibre GL JS · API reference

Layer

Quick answer

Layer is the declarative draw instruction passed to map.addLayer, pairing a source with a type and paint and layout rules. Type decides geometry handling: fill, line, circle, symbol, heatmap, fill-extrusion, raster, hillshade or background. filter plus minzoom and maxzoom narrow what renders without changing the data.

Last verified 2026-11-03 · MapLibre GL JS 4.x · Cite this page
map.addLayer( layer , beforeId )
Key points
Example
map.addLayer({
  id: 'zones-fill',
  type: 'fill',
  source: 'zones',
  paint: {
    'fill-color': ['get', 'color'],
    'fill-opacity': 0.35
  }
}, 'labels');   // 插到 labels 图层下面
map.addLayer({
  id: 'major-roads',
  type: 'line',
  source: 'base',
  'source-layer': 'roads',
  filter: ['all',
    ['==', ['get', 'class'], 'primary'],
    ['>', ['get', 'length'], 500]
  ],
  minzoom: 8,
  paint: { 'line-color': '#c2410c', 'line-width': 2 }
});
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). Layer. https://www.jingweizhi.com/en/maplibre/api/layer.html (accessed 2026-11-03).