# Live map

> The world as dots, lighting up where things happen: pings ripple, the light lingers, and one card follows the newest event from city to city.

"Used in 140 countries" is a sentence; this is the feeling. The continents are an even field of dots, and every time something happens somewhere (a signup, an order, a deploy) the dots around it light up and a hairline ring ripples out. The light fades slowly, so the last minute of activity stays on the map as a faint tint that shows where people are. One card follows the newest event, gliding from Lisbon to Tokyo with its words morphing rather than stacking up popups, and swinging to the other side near an edge. Give an event a starting point and a route arcs across from there, with a short dash running along it like a parcel. Fixed places, an office or a roastery, sit as rings.

## Install

```bash
npx shadcn@latest add https://hairlineui.com/r/live-map.json
```

Needs React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.

- npm: none
- Hairline UI components it needs (the CLI installs them too): `text-morph`
- Docs and live preview: https://hairlineui.com/ui/live-map
- Registry item (source): https://hairlineui.com/r/live-map.json

## Usage

```tsx
import { LiveMap } from "@/components/live-map";

<LiveMap
  pings={[
    { id: 1, lat: 38.7, lon: -9.1, label: "New signup", detail: "Lisbon, Portugal" },
    { id: 2, lat: 35.7, lon: 139.7, label: "New signup", detail: "Tokyo, Japan" },
  ]}
/>
```

## From an event stream

Keep the last dozen events and pass them in; ids the map hasn’t seen before ping once. Cities can come from your geo-IP lookup.

```tsx
"use client";
import { useEffect, useState } from "react";
import { LiveMap, type MapPing } from "@/components/live-map";

const STORE = { lat: 38.7, lon: -9.1 };

export function OrdersMap() {
  const [pings, setPings] = useState<MapPing[]>([]);
  useEffect(() => {
    const source = new EventSource("/api/orders/stream");
    source.onmessage = (e) => {
      const order = JSON.parse(e.data); // { id, total, city, country, lat, lon }
      setPings((all) => [
        ...all.slice(-11),
        { id: order.id, lat: order.lat, lon: order.lon, label: `Order · $${order.total}`, detail: `${order.city}, ${order.country}`, from: STORE },
      ]);
    };
    return () => source.close();
  }, []);
  return <LiveMap pings={pings} markers={[STORE]} />;
}
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `pings` | `{ id, lat, lon, label?, detail?, from? }[]` | – | Recent events, oldest first. Each id pings once, the first time it’s seen. |
| `markers` | `{ lat, lon, label? }[]` | – | Places that are always marked, like a store or an office. |
| `afterglow` | `number` | `9000` | Milliseconds for a ping’s light to fade to its faint tint. |
| `showLabel` | `boolean` | `true` | Show the card on the newest ping. |

## States

- **land**: A staggered grid every 2.6° sampled against hand-drawn coastlines (no map data to load), drawn as one path; cropped between 76°N and 56°S.
- **ping**: Dots within about 5° light in the primary colour, brightest at the centre; a 1px ring scales out and fades (1.4s). The light holds briefly, then fades to a faint tint over afterglow (9s by default).
- **card**: Follows the newest ping (620ms glide); its two lines morph letter by letter; flips left near the right edge and below near the bottom.
- **route**: With from, a curve lifted in proportion to the distance draws itself (pathLength 1), a 2px dash runs from end to end (1.5s), then the curve fades.
- **markers**: A hairline ring with a dot in the middle, always shown.

## What it handles

“Used in 140 countries” is a sentence. A map that lights up as things happen is a feeling. This draws one from dots, with no map data to load.

- **The world as dots**: Hand-drawn coastlines are sampled into an even field of dots, so there is nothing to download.
- **Pings from latitude and longitude**: Each event lights the dots around it and sends a hairline ring rippling out.
- **Light that lingers**: The glow fades slowly, 9 seconds by default, so recent activity stays on the map as a faint tint.
- **One card for the newest event**: A single card glides from city to city, its words morphing, instead of popups stacking up.
- **Routes between places**: Give an event a starting point and a curve arcs across from there, with a short dash running along it.
- **Markers and screen readers**: Fixed places such as an office show as rings, and each new event is announced politely.

## Replaces

a map library, map tiles, a GeoJSON file, ping animations, an event card

## Where it fits

- **Landing page proof**: Show that people around the world use the product, instead of stating it.
- **Real-time dashboards**: Signups and orders appearing on a map as they happen.
- **Launch day pages**: A live view of the first sign-ups or downloads.
- **Ops and admin dashboards**: Where deploys, requests or users are coming from.

## Notes

- The map is decorative to assistive tech; each new event’s label and detail are announced through a polite status region.
- Points use plain latitude and longitude; the projection is a stretched equirectangular, so it reads like the maps people know without a library.
- The coastlines are deliberately coarse; at this dot size the detail wouldn’t show. Antarctica and the far north are cropped.
- Installs Text morph. With reduced motion nothing ripples, glides or draws; pings simply light their dots.

License: MIT (https://hairlineui.com/license#components)
