Skip to content

MapLibre examples in YAML

The MapLibre GL JS examples are the standard set of small web-map recipes. This gallery rebuilds them as maplibre-yaml documents: each page runs the example live and shows the YAML that draws it, ready to copy. Use it to look up one technique. For a guided start, see the examples overview.

MapLibre's gallery has 139 examples, and 104 of them have a page here: 79 in YAML alone and 25 with some page JavaScript. The rest are listed, folded, under each group, with what you would write instead. The gallery also has 4 pages of its own: files read straight from a web server, and two Mapzen classics.

Every gallery page has the same parts:

  1. A link to the MapLibre original, and what the YAML version does differently.
  2. The map, running live.
  3. The complete document: the YAML file the map above loads, exactly as it runs.
  4. What to notice: the lines that do the work.
  5. Use this map: how to put it on your own page, and the guide and reference for what it uses.

The badge next to each example says what you write:

  • YAML One YAML document and nothing else.
  • YAML + JavaScript A YAML document plus a few lines of page JavaScript, for the part that is behaviour rather than a description of the map, such as a button that moves the camera. These pages show three parts in place of the complete document: the YAML, the page HTML that goes inside the <ml-map> element (an element with a slot attribute sits in a corner of the map), and the JavaScript. The JavaScript gets the map from the element’s mapReady() method.
  • JavaScript Work that belongs in MapLibre code rather than a map document, such as a game loop or a 3D Tiles renderer. These have no page here; follow the link to the MapLibre example.

Not in MapLibre’s gallery: data files read in parts, straight from a web server, with no tile server and no page JavaScript. How they work and how to host them: Large data.

Not in MapLibre’s gallery: two looks from the Mapzen Tangram era, rebuilt in plain style properties. Mapzen classics runs them with experimental effects, next to their exported style.json.