Atlaslog
Atlaslog / Leaflet / Tutorial / Build your first map in ten minutes
Leaflet · Tutorial

Build your first map in ten minutes

Quick answer

This tutorial builds a complete Leaflet page from a CDN stylesheet and script, a sized map container and an L.map initialized with center and zoom. It adds an L.tileLayer using the {z}/{x}/{y} template with maxZoom and attribution. It explains the three points beginners miss: the container needs a real height, coordinates are [lat, lng], and swapping the tile URL changes the basemap. Readers end with a draggable, zoomable map of their own.

Last verified 2026-11-03 · Leaflet 1.9.4 · 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/leaflet@1.9.4/dist/leaflet.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/leaflet@1.9.4/dist/leaflet.js"></script>
  <script>
    var map = L.map('map', {
      center: [39.907359, 116.391263],
      zoom: 11
    });

    L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
      maxZoom: 19,
      attribution: '&copy; OpenStreetMap contributors'
    }).addTo(map);
  </script>
</body>
</html>
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). Build your first map in ten minutes. https://www.jingweizhi.com/en/leaflet/tutorials/minimal-scene.html (accessed 2026-11-03).