Skip to content
Agents tracked: 440 Downloads (7d): 202M down 19.5% GitHub stars: 10.4M Releases (7d): 607 Agent status: 1 with issuesSince last limit reset: Claude 28d · Codex 0d Updated Oct 21, 2026

React Leaflet Examples You Can Edit and Run

5 small React Leaflet examples written by AgentGid from the official docs, one feature each. Every one runs in your browser: change the code and see the result at once, or describe a change and let AI rewrite it. The screenshots are taken from the same code by our server, which also checks that each example starts without errors.

React Leaflet: usage and stats 60 AI-built projects use it

Try them all in one place

import { MapContainer, Marker, Popup, Polygon, Polyline, Circle } from "react-leaflet";
import L from "leaflet";

// A marker icon drawn with HTML and CSS (no image files)
const pin = (color) => L.divIcon({ className: "", iconSize: [20, 20], iconAnchor: [10, 10],
  html: `<div style="width:14px;height:14px;border-radius:50%;background:${color};border:3px solid #fff;box-shadow:0 0 0 2px rgba(0,0,0,.4)"></div>` });

const position = [51.505, -0.09];
const park = [[51.512, -0.125], [51.517, -0.1], [51.511, -0.082], [51.503, -0.104]];
const river = [[51.494, -0.14], [51.5, -0.11], [51.497, -0.08], [51.503, -0.05]];

export default function App() {
  return (
    <MapContainer center={position} zoom={13} scrollWheelZoom={false} style={{ height: "100vh", background: "#0b1626" }}>
      <Polygon positions={park} pathOptions={{ color: "#22c55e", fillOpacity: 0.3 }} />
      <Polyline positions={river} pathOptions={{ color: "#38bdf8", weight: 8, opacity: 0.8 }} />
      <Circle center={[51.508, -0.06]} radius={500} pathOptions={{ color: "#f59e0b" }} />
      <Marker position={position} icon={pin("#f43f5e")}>
        <Popup>
          A pretty CSS3 popup. <br /> Easily customizable.
        </Popup>
      </Marker>
    </MapContainer>
  );
}
Ctrl/⌘ + Enter runs

Free for signed-in members, with a daily limit. Describe the change in plain words; the new code runs only in your browser.

Click the pink marker to open its popup, and drag the map to pan around the shapes. Code written by AgentGid [1]. How it works, with a screenshot →

Checked Oct 12, 2026: each example starts without errors in Chromium with react-leaflet 5.0.0, react 19.3.0, react-dom 19.3.0, leaflet 1.9.4. Needs WebGL.

Sources

  1. React Leaflet website
  2. Docs: docs › start-introduction
  3. Docs: docs › api-map

Explanations written by AgentGid from the official docs; the numbers in brackets point here. The code marked "written by AgentGid" is ours and free to copy.

Building something with React Leaflet? Ask AgentGid →