Atlaslog
Atlaslog / MapLibre GL JS / Tutorial / Your first MapLibre map
MapLibre GL JS · Tutorial

Your first MapLibre map

Quick answer

This tutorial builds the smallest working map: a container with an explicit height, the maplibre-gl stylesheet and script, a required style URL, and a new maplibregl.Map with center and zoom. It stresses [lng, lat] ordering, adding sources and layers inside the load callback, and the four control positions. You will be able to bootstrap a page and diagnose a blank map.

Last verified 2026-11-03 · MapLibre GL JS 4.x · Cite this page
Key points
Example
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/maplibre-gl@4/dist/maplibre-gl.css">
  <style>
    html, body { height: 100%; margin: 0; }
    #map { height: 100%; }
  </style>
</head>
<body>
  <div id="map"></div>
  <script src="https://cdn.jsdelivr.net/npm/maplibre-gl@4/dist/maplibre-gl.js"></script>
  <script>
    var map = new maplibregl.Map({
      container: 'map',
      style: 'https://demotiles.maplibre.org/style.json',
      center: [116.391263, 39.907359],
      zoom: 4
    });

    map.addControl(new maplibregl.NavigationControl(), 'top-right');
  </script>
</body>
</html>
map.on('load', function () {
  map.addSource('points', {
    type: 'geojson',
    data: { type: 'Point', coordinates: [116.39, 39.90] }
  });

  map.addLayer({
    id: 'points',
    type: 'circle',
    source: 'points',
    paint: { 'circle-radius': 6, 'circle-color': '#1f5fd0' }
  });
});
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). Your first MapLibre map. https://www.jingweizhi.com/en/maplibre/tutorials/minimal-scene.html (accessed 2026-11-03).