dotted‑world‑map

World maps, drawn in dots.

Dotted World Map draws the world, a region or any country as an SVG of dots or hexagons, with pins where you want them. It returns a string, so it works on the server and in the browser, with any framework or none.

npm install @setkernel/dotted-map-next

World map in dotsSix orange pins mark New York, São Paulo, London, Lagos, Mumbai and Tokyo.
The world on a diagonal grid, with pins on six cities. Every map on this page is drawn by the library when the site is built.

Quick start

Make a map, add pins, and ask for the SVG. The result is a plain string: write it to a file, send it from a server, or put it straight into your page.

import dottedMap from '@setkernel/dotted-map-next';

const DottedMap = dottedMap.default; // 2.0 exports { DottedMap } by name

const map = new DottedMap({ height: 60, grid: 'diagonal' });

map.addPin({
  lat: 48.8534,
  lng: 2.3488,
  svgOptions: { color: '#e8590c', radius: 0.6 },
});

const svg = map.getSVG({ shape: 'circle', radius: 0.3, color: '#1f2328' });

Playground

Every 2.0 option, drawn live in your browser by the library from main, before 2.0 is on npm. The code under the map draws what you see, with only the options you changed: the empty fields show the defaults. The address bar keeps your settings, so its link draws the same map.

Start from a preset
Map new DottedMap({…})
region, in degrees
grid
SVG getSVG({…})
shape
Pins addPin({…})
Preview

What you get

Any country, any region
Pass ISO 3166-1 alpha-3 codes, or a box of latitude and longitude. The map fits the grid to what you asked for.
Pins on the grid
A pin snaps to the nearest dot and takes its own colour and size. Keep pins off the sea with avoidOuterPins.
Fast repeat maps
Compute a map once with getMapJSON, then draw it from the small without-countries entry with no country data in your bundle.
Typed
TypeScript types ship with the package.

Guides

Questions

What is Dotted World Map?
Dotted World Map is a free, open-source JavaScript library that draws the world, a region or any country as an SVG made of dots or hexagons. You give it a size and, if you like, pins; it gives you back an SVG string.
How do I make a dotted world map in JavaScript?
Install @setkernel/dotted-map-next, create a map with a height, and call getSVG(), which returns the map as an SVG string. Add pins with addPin() before that call.
Can it draw one country or one region?
Yes: pass countries with ISO 3166-1 alpha-3 codes, such as ['FRA'], or region with a box of latitude and longitude. The grid fits what you asked for.
Does it work with React, Vue, Svelte, Next.js or Astro?
Yes: the map is an SVG string, so every framework can render it. Use dangerouslySetInnerHTML in React, v-html in Vue, {@html} in Svelte and set:html in Astro. In Next.js or Astro you can draw it on the server, so the browser downloads no map code at all.
Does it run on the server or at the edge?
Yes: it uses no DOM, no canvas and no Node.js modules, so it runs in Node.js, in edge functions and in the browser. Draw a map once at build time and ship plain SVG, as this page does.
How do I add pins or markers?
Call addPin({ lat, lng }) before getSVG(). The pin snaps to the nearest dot and can have its own colour and radius; avoidOuterPins keeps pins off the sea.
Is it free to use?
Yes: it is open source under the MIT licence, free for personal and commercial use.

2.0 is on its way

Smaller SVG output, typed pin data, maps a screen reader can name, and the playground above, where you can tune every option and copy the code. Follow the work on GitHub.