Map explorerPro
A choropleth of US states or world countries with zoom, search, a ranked list and metric switching.
pnpm dlx shadcn@latest add @lode/map-explorerWhat's inside
- US states and world countries
- Click to fly into a place
- Ranked list and search synced with the map
- Three metrics with quantile colours
When to use
- Sales, users or usage that differ by region.
- Spotting where to focus: the best and worst places at a glance.
When not to use
- Comparing exact values between a handful of places: a bar chart is clearer.
- Values that just follow population: show per-person rates instead.
Installation
pnpm dlx shadcn@latest add @lode/map-explorerLands in components/blocks/map-explorer.tsx with sample data you replace with your own. Pro installs use an API key: see CLI and API keys.
The CLI also installs motion, lucide-react, d3-geo, topojson-client, us-atlas, world-atlas and every Lode component it's built from.
Usage
Import it from @/components/blocks/map-explorer after installing. It ships with sample data, so it renders straight away; swap in your own data when you're ready.
import { MapExplorer } from "@/components/blocks/map-explorer";
export default function Page() {
return (
<main className="mx-auto max-w-6xl p-6">
<MapExplorer />
</main>
);
}API reference
MapExplorer
A choropleth of US states or world countries: switch metric, click a place to fly in, and browse a ranked, searchable list that stays in sync with the map. Also the default export. No props: sample data sits at the top of the file, ready to swap for your own.
No props.
Keyboard interactions
| Keys | Action |
|---|---|
| Tab | Reach the metric and region toggles, zoom buttons, search and list |
| Enter | Select a place in the list and fly to it |
| Escape | Clear the selection and zoom out |
Accessibility
- The map has a text summary; every value is in the ranked list, which is the keyboard route.
- List items are buttons with aria-pressed for the selected place.
Motion
- The view flies to a place on a spring; colours fade when the metric changes.
- With reduced motion the view jumps instead.
Responsive behavior
- The list moves below the map under 768px; the map keeps its aspect ratio.
Performance
- Map shapes load only when a region is first shown (about 85 KB for US states, 110 KB for the world).
- Sample data is plain arrays at the top of the file. Replace them with your API data and keep the shapes.
Notes for AI
- Replace sample() with a lookup by state or country name (or its id).
- Colours are quantiles, so each shade covers about the same number of places.
This page as Markdown, for assistants and coding agents:
/blocks/map-explorer/markdownThe full library index for assistants is at /llms.txt.
Related
Lode·227 doc pages·llms.txt