Dotted World Map

A lightweight SVG world map made of dots, each tinted by a value. Drop it into analytics, hero sections, or anywhere you need a quiet global pulse.

Fewer visitorsMore visitors

Installation

Dotted World Map is published as a shadcn registry item. The CLI drops the file into your project, installs its dependencies, and adds any primitives it relies on.

$npx shadcn@latest add https://akoder.xyz/r/dotted-world-map.json

Install often? Register the namespace once in components.json and use the shorter form npx shadcn@latest add @akoder/dotted-world-map.

Usage

import { DottedWorldMap } from "@/components/ui/dotted-world-map";
 
const weeklyVisitors = [
  {
    name: "London",
    lat: 51.5074,
    lng: -0.1278,
    value: 0.9,
    radius: 12,
    tooltip: "London — 1,120 visitors this week",
  },
  {
    name: "Tokyo",
    lat: 35.6762,
    lng: 139.6503,
    value: 0.8,
    radius: 12,
    tooltip: "Tokyo — 980 visitors this week",
  },
  {
    name: "New York",
    lat: 40.7128,
    lng: -74.006,
    value: 0.95,
    radius: 13,
    tooltip: "New York — 1,240 visitors this week",
  },
];
 
export function VisitorsMap() {
  return (
    <DottedWorldMap
      points={weeklyVisitors}
      dotRadius={1.6}
      spacing={5}
      legendLabels={{ low: "Fewer visitors", high: "More visitors" }}
    />
  );
}

Props

PropTypeDefaultNotes
pointsArray<{ name: string; lat: number; lng: number; value: number; radius?: number; tooltip?: string }>requiredvalue (0–1) controls heat and marker color. tooltip supplies the hover and keyboard detail. Points with value < 0.02 are skipped.
colorsstring[]green → red scaleColor scale interpolated by value. Pass CSS variables (e.g. --heatmap-level-*) to adapt to light/dark automatically.
baseColorstringcolors[0]Color for the low-intensity land dots.
dotRadiusnumber1.7Radius of an individual land dot in SVG units. Point markers are drawn larger for reliable hover and focus.
spacingnumber6Distance between land-dot centers. Smaller = denser.
colsnumber120Grid resolution — width in dots.
rowsnumber60Grid resolution — height in dots. Defaults to a 2:1 aspect ratio.
baseOpacitynumber0.2Opacity of the land dots.
showMarkersbooleantrueRenders an interactive marker per point. Set false for a pure heatmap (e.g. density illustration).
showLegendbooleantrueShows a GitHub-style color scale legend below the map.
legendLabels{ low?: string; high?: string }{ low: "Less", high: "More" }Labels at the two ends of the legend.
classNamestringClasses applied to the <svg> element.

Notes

Manual installation

The CLI is the supported path. If you would rather not use it, copy components/ui/dotted-world-map.tsx into your project. It is self-contained: the only imports are cn from @/lib/utils and the shadcn tooltip primitive, so make sure both exist before dropping the file in.

Examples

Explore different presets, palettes, and configurations.

Population density

A marker-free heatmap — warm dots for dense regions, cool dots for sparse ones.

SparseDense

Illustrative population density — not live census data.

Example 1 of 4: Population density