Leaflet
~42kb gzipped (JS) + ~4kb CSSMobile-friendly interactive maps in ~42kb -- pan, zoom, and drop markers with a few lines of code.
See It in Action
Each demo loads a real-world tile map and adds markers, popups, or routes. Drag to pan, scroll to zoom, click markers to open popups.
A real-world tile map zoomed on Cairo with a single marker and an open popup -- the classic "Find us" widget for a business contact page.
What is Leaflet?
Leaflet is a JavaScript library for interactive maps. You drop a <div> on the page, point Leaflet at it, pick a tile provider, and you have a pannable, zoomable, mobile-friendly map -- no API key, no build step.
Created in 2011 by Volodymyr Agafonkin, Leaflet has stayed simple on purpose: ~42kb gzipped, zero npm dependencies, and a small API focused on tiles, markers, popups, and shapes. It is the default choice for store locators, travel maps, and most "show this address on a map" use cases on the web.
When to Use Leaflet
How Leaflet Compares
MapLibre is the modern WebGL choice for vector tiles, smooth zoom, 3D terrain, and runtime styling. Leaflet is the simpler, lighter raster-tile choice that just works without GPU dependencies. Pick Leaflet for marker-on-a-map use cases; pick MapLibre when you need vector styling or 3D.
Mapbox GL JS v2+ uses a proprietary license that bills per map load -- a non-starter for many commercial projects. Leaflet is BSD-2-Clause and free with OpenStreetMap or CartoDB tiles. Use Mapbox only if you already pay for their tile service.
Google Maps charges per map load after a small free tier and requires an API key on a billing account. Leaflet + free OSM tiles costs zero forever. Use Google Maps if you specifically need Street View, Places search, or branded Google tiles.
OpenLayers is the heavier, GIS-grade option -- supports more projections, formats, and analysis features. Leaflet is the lighter, beginner-friendly pick for typical website maps. Choose OpenLayers for GIS apps; choose Leaflet for store locators and travel maps.
Get Started with Leaflet
npm install leaflet
yarn add leaflet
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/leaflet.css">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/leaflet.js"></script>
<!-- In your <head> -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/leaflet.css">
<!-- In your <body> -->
<div id="map" style="height: 400px;"></div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/leaflet.js"></script>
<script>
// Center the map on a city, zoom level 13
const map = L.map("map").setView([30.0444, 31.2357], 13);
// Pick a tile provider (OpenStreetMap is free + needs no key)
L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
attribution: "© OpenStreetMap contributors"
}).addTo(map);
// Drop a marker with a popup
L.marker([30.0444, 31.2357])
.addTo(map)
.bindPopup("Hello from Cairo!")
.openPopup();
</script>