npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@wescld/dotted-map

v1.0.0

Published

Interactive dotted globe and flat map component for React — pure Canvas 2D, zero WebGL

Readme

demo

Features

  • Globe + Flat map — switch between 3D orthographic globe and 2D equirectangular projection
  • Pure Canvas 2D — no WebGL, no Three.js. The 3D globe is rendered with manual orthographic projection math
  • Smart clustering — two-phase clustering (geo-grid + screen-space merge) with animated transitions
  • Custom markers — render any React component as a marker via renderMarker
  • Dark/Light mode — built-in theme support with full customization
  • Drag, zoom, auto-rotate — smooth interactions with configurable zoom range
  • Tiny footprint — zero runtime dependencies, React as peer dep
  • SSR-safe — canvas rendering only runs in the browser

Install

npm install @wescld/dotted-map

Quick start

import { DottedMap } from "@wescld/dotted-map";

const markers = [
  { id: "ny", latitude: 40.71, longitude: -74.01, data: { name: "New York" } },
  { id: "ld", latitude: 51.51, longitude: -0.13, data: { name: "London" } },
  { id: "tk", latitude: 35.68, longitude: 139.69, data: { name: "Tokyo" } },
];

function App() {
  return (
    <DottedMap
      markers={markers}
      defaultViewMode="globe"
      darkMode
      onMarkerClick={(cluster) => {
        console.log(cluster.markers);
      }}
    />
  );
}

Custom markers

Use renderMarker to render any React element at each marker position:

<DottedMap
  markers={markers}
  renderMarker={(marker, position, isActive) => (
    <div
      style={{
        width: 24,
        height: 24,
        borderRadius: "50%",
        background: isActive ? "#22c55e" : "#f97316",
        display: "flex",
        alignItems: "center",
        justifyContent: "center",
        color: "white",
        fontSize: 10,
        fontWeight: 700,
      }}
    >
      {marker.data?.name?.[0]}
    </div>
  )}
/>

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | markers | MarkerData[] | [] | Array of markers to display | | defaultViewMode | "globe" \| "flat" | "flat" | Initial view mode (uncontrolled) | | viewMode | "globe" \| "flat" | — | Controlled view mode | | onViewModeChange | (mode) => void | — | Called when view mode changes | | activeMarkerIds | Set<string> \| string[] | — | IDs of markers to highlight as active | | onMarkerClick | (cluster) => void | — | Called when a marker/cluster is clicked | | renderMarker | (marker, pos, isActive) => ReactNode | — | Custom marker renderer | | theme | DottedMapTheme | — | Theme overrides | | darkMode | boolean | false | Enable dark mode | | className | string | — | CSS class for the container | | style | CSSProperties | — | Inline styles for the container | | initialRotation | [lng, lat] | [-40, 0] | Initial globe rotation | | autoRotate | boolean | false | Enable auto-rotation on the globe | | zoomRange | [min, max] | [0.8, 5] | Min/max zoom levels | | clusterCellDegrees | number | 15 | Geo-grid cell size for clustering |

MarkerData

interface MarkerData {
  id: string;
  latitude: number;
  longitude: number;
  data?: Record<string, unknown>;
}

DottedMapTheme

interface DottedMapTheme {
  dotColor?: string;
  globeFill?: string;
  outlineColor?: string;
  clusterColor?: string;
  clusterTextColor?: string;
  clusterBorderColor?: string;
  activeGlow?: string;
  activeBadgeColor?: string;
}

Icons

The package exports GlobeIcon and FlatMapIcon components for building view mode toggles:

import { GlobeIcon, FlatMapIcon } from "@wescld/dotted-map";

<button onClick={() => setMode("flat")}><FlatMapIcon /></button>
<button onClick={() => setMode("globe")}><GlobeIcon /></button>

How it works

The 3D globe is not WebGL — it's an orthographic projection computed on a 2D canvas. Each of the 4,577 pre-generated land points is projected frame-by-frame using sin/cos math, with back-face culling to hide points on the far side.

Clustering runs in two phases:

  1. Geo-grid — markers are grouped by latitude/longitude cells
  2. Screen-space merge — nearby clusters within 50px are merged after projection

Transitions between zoom levels and view modes are animated with proximity-matched lerping for smooth cluster morphing.

Demo

cd packages/react-dotted-map
npm run demo
# opens on http://localhost:3333

License

MIT