Atlaslog
Atlaslog / MapLibre GL JS / Tutorial / The style specification
MapLibre GL JS · Tutorial

The style specification

Quick answer

This tutorial explains the style specification as a JSON contract: the mandatory version: 8, sources, layers, and optional sprite, glyphs, center, terrain, light and sky. It lists layer types such as background, fill, line, circle, symbol, raster, fill-extrusion, heatmap and hillshade with their required geometry, and shows a minimal inline style object. You will be able to validate a style and know why a map stays blank.

Last verified 2026-11-03 · MapLibre GL JS 4.x · Cite this page
Key points
Example
var style = {
  version: 8,
  sources: {
    base: {
      type: 'raster',
      tiles: ['https://tile.openstreetmap.org/{z}/{x}/{y}.png'],
      tileSize: 256,
      attribution: '© OpenStreetMap contributors'
    }
  },
  layers: [
    {
      id: 'bg',
      type: 'background',
      paint: { 'background-color': '#0d1117' }
    },
    {
      id: 'base-tiles',
      type: 'raster',
      source: 'base',
      paint: { 'raster-opacity': 0.85 }
    }
  ]
};

var map = new maplibregl.Map({
  container: 'map',
  style: style,
  center: [116.391263, 39.907359],
  zoom: 4
});
{
  "id": "countries-fill",
  "type": "fill",
  "source": "base",
  "source-layer": "countries",
  "filter": ["==", ["geometry-type"], "Polygon"],
  "paint": {
    "fill-color": ["match", ["get", "continent"], "Asia", "#f2e8d5", "#e8eef4"],
    "fill-opacity": 0.9
  }
}
Notes
Runnable examplesChinese originalAll Tutorials
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Cite this page

Atlaslog (2026). The style specification. https://www.jingweizhi.com/en/maplibre/tutorials/style-spec.html (accessed 2026-11-03).