Choropleth globe
ISO country polygons on globe.gl, flush land caps, readable borders, optional auto-center.
Lit · globe.gl · country polygons
Drop in <globe-chart>, pass ISO + values, and ship a polished 3D map —
legend, search, themes, camera, and toast feedback included. MIT for open source;
commercial use needs approval.
A small API surface with the pieces you need in a real product.
ISO country polygons on globe.gl, flush land caps, readable borders, optional auto-center.
Show/hide, left/right, max height, collapsible toggle (mobile-friendly), paging, local or remote search.
theme="light|dark|auto" plus CSS variables for ocean, scale, legend, and strokes.
Skipped rows and init failures surface as in-component toasts and globe-error / globe-warning events.
Nested config for colors, camera, labels, globe visuals, and toast placement.
Plain custom element — works with React, Vue, Svelte, or vanilla. One install: npm i globe-chart.
npm install globe-chart
Published on
npm.
One command, zero configuration: lit, globe.gl, and
three install as dependencies, and the country map ships inside the
package as a lazily code-split module — no asset copying, no loader plugins, no
CDN fetch. Everything stays external to the published bundle so your app does not
double-ship WebGL stacks.
The same component, integrated idiomatically — each demo is a small open-source app deployed from its own repo.
Typed globe-chart/react wrapper with event callbacks.
Live demo ·
Source
Signals, OnPush, and declarative [prop] bindings.
Live demo ·
Source
:data.prop bindings and typed @country-select listeners.
Live demo ·
Source
Native custom-element property binding, no wrapper at all. Live demo · Source
Full details live in the README. The essentials:
| Property | Attribute | Notes |
|---|---|---|
data |
— | Rows with ISO + numeric value |
showLegend |
legend |
Overlay legend (default off) |
theme |
theme |
light · dark · auto |
config |
— | Legend, colors, camera, toasts… |
loading |
loading |
Empty rolling globe |
el.config = {
legend: {
title: 'By country',
maxHeight: '280px', // CSS length
pageSize: 8,
search: { enabled: true, mode: 'local' },
},
};
el.config = {
legend: {
collapsible: true,
collapseMode: 'mobile', // 'never' | 'always' | 'mobile'
collapseOnSelect: 'mobile', // 'never' | 'mobile' | 'always'
mobileBreakpoint: '(max-width: 768px)',
toggleLabel: 'Legend',
},
};
Desktop keeps the panel open after a country click. On mobile, selecting a country
collapses back to the button by default. Use collapseOnSelect: 'always'
if you want that behavior on every viewport.
ready — globe initializedcountry-select — legend / polygon selectioncountry-hover — pointer over a country (detail: null on leave)legend-search — remote/hybrid search requestglobe-error / globe-warning — feedback payloadel.select('FR'); // highlight + fly to France
el.select(null); // clear selection
el.flyTo('JP'); // camera only, keeps selection
el.flyTo({ lat: 48.8, lng: 2.3, altitude: 1.5 });
el.selectedIso; // current selection, or null
Set theme on the element, or override CSS variables:
--globe-chart-ocean-color,
--globe-chart-low-color,
--globe-chart-high-color,
--globe-chart-legend-max-height, and more.
Open source (OSI-approved): free under MIT. Proprietary / commercial: written approval required — see COMMERCIAL.md or email benjiar@gmail.com.
Country outlines: Natural Earth 110m admin-0 (public domain).