Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Builds interactive Leaflet.js maps with tile layers, markers, popups, vector shapes and geolocation for web applications.
64% 86%+23 ptsof test cases passed
Passed 19 of 22 test cases with the skill, and 14 of 22 without it.
3 of 3 safety checks passed
29 agent runs
Leaflet is a lightweight open-source JavaScript library for interactive maps: raster tile layers, markers, popups, vector shapes, GeoJSON and map events, with clustering and other features added by plugins. It has no API key of its own — the tiles come from a provider you choose, such as OpenStreetMap. In React it is used through react-leaflet, which wraps the same Leaflet objects in components.
The stable release is 1.9.4 (May 2023) and it is what npm install leaflet installs. Leaflet 2.0 is still an alpha (2.0.0-alpha.1, August 2025): it is ESM-only and drops the global L and the factory functions (L.marker(latlng) becomes new Marker(latlng)), while react-leaflet 5 and plugins written for the global L still require 1.9. Use 1.9.4 unless the user asks for 2.0.
npm install leaflet
npm install -D @types/leaflet # TypeScript types (Leaflet 1.9 ships none)
# React 19
npm install react-leaflet react-leaflet-cluster # react-leaflet 5, cluster 4
# React 18 (the unpinned command above fails there with ERESOLVE)
npm install react-leaflet@4 react-leaflet-cluster@3
Without a build step, load the pinned CDN files as in Example 1. The map container needs an explicit height and leaflet.css must be loaded: without the height the map is invisible, without the CSS the tiles are scattered over the page.
import L from "leaflet";
import "leaflet/dist/leaflet.css";
const map = L.map("map").setView([52.3738, 4.888], 13); // id of a <div> with a height
L.tileLayer("https://tile.openstreetmap.org/{z}/{x}/{y}.png", {
maxZoom: 19,
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
}).addTo(map);
L.marker([52.3738, 4.888]).addTo(map).bindPopup("<b>Amsterdam HQ</b><br>Herengracht 182");
L.circle([52.3738, 4.888], { radius: 1500, color: "#2563eb" }).addTo(map); // radius in metres
Next to this one in the catalogue, plus popular skills in the same category.