Heatmaps
A month of earthquakes as a heatmap by magnitude, dots when zoomed in, volcanoes as pins, a checkbox for each.
Map and code
Loading the map…
The map couldn't load.
Loading the map…
The map couldn't load.
Loading the map…
The map couldn't load.
Loading the map…
The map couldn't load.
Loading the map…
The map couldn't load.
Loading the map…
The map couldn't load.
Loading the map…
The map couldn't load.
Loading the map…
The map couldn't load.
These maps come from Google Maps and OpenFreeMap, which see your IP address. They stay off until you say so, once for the whole site. What loading the maps sends
Fetches earthquakes.json, volcanoes.json
<!doctype html>
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element-maplibre.iife.js"></script>
<style>
/* On a phone the list goes under the map, its half staying that size as the quakes narrow. */
@media (width < 40rem) {
#earthquakes-maplibre-map { height: 36rem; }
#earthquakes-maplibre-map > .maplace-list { flex: 0 0 50%; max-height: 50%; }
}
</style>
<!-- A month of earthquakes of magnitude 4.5 and up, to November 2026 (USGS, in earthquakes.json), as a heatmap weighted by magnitude, with volcanoes (volcanoes.json) as pins: zoomed in, the heat fades into a dot per quake, and the list's search and its checkbox for each group narrow the heat with it. -->
<maplace-map id="earthquakes-maplibre-map" heatmap="Quakes" center="20,160" zoom="2" list search
search-label="Find a quake or a volcano" group-filter></maplace-map>
<script type="module">
// The quakes, each weighing its magnitude, in the group the heatmap draws; the volcanoes, pins.
const [quakes, volcanoes] = await Promise.all([
fetch("/examples/data/earthquakes.json").then((response) => response.json()),
fetch("/examples/data/volcanoes.json").then((response) => response.json()),
]);
document.getElementById("earthquakes-maplibre-map").locations = [...quakes, ...volcanoes];
</script><!doctype html>
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element.iife.js"></script>
<style>
/* On a phone the list goes under the map, its half staying that size as the quakes narrow. */
@media (width < 40rem) {
#earthquakes-map { height: 36rem; }
#earthquakes-map > .maplace-list { flex: 0 0 50%; max-height: 50%; }
}
</style>
<!-- A month of earthquakes of magnitude 4.5 and up, to November 2026 (USGS, in earthquakes.json), as a heatmap weighted by magnitude, with volcanoes (volcanoes.json) as pins: zoomed in, the heat fades into a dot per quake, and the list's search and its checkbox for each group narrow the heat with it. -->
<maplace-map id="earthquakes-map" api-key="YOUR_KEY" heatmap="Quakes" center="20,160" zoom="2" list search
search-label="Find a quake or a volcano" group-filter></maplace-map>
<script type="module">
// The quakes, each weighing its magnitude, in the group the heatmap draws; the volcanoes, pins.
const [quakes, volcanoes] = await Promise.all([
fetch("/examples/data/earthquakes.json").then((response) => response.json()),
fetch("/examples/data/volcanoes.json").then((response) => response.json()),
]);
document.getElementById("earthquakes-map").locations = [...quakes, ...volcanoes];
</script><!doctype html>
<!-- A page of your own script: the MapLibre CDN script, which bundles maplibre-gl and its stylesheet and what the map and its list mount on, and the map made with Maplace; the quakes as a heatmap by magnitude, the volcanoes as pins. -->
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element-maplibre.iife.js"></script>
<style>
#earthquakes-maplibre-script-map-and-list { display: flex; height: 24rem; }
#earthquakes-maplibre-script-map { flex: 1 1 auto; min-width: 0; }
#earthquakes-maplibre-script-list { display: contents; }
#earthquakes-maplibre-script-list .maplace-list { flex: 0 1 16rem; }
/* On a phone the list goes under the map, its half staying that size as the quakes narrow. */
@media (width < 40rem) {
#earthquakes-maplibre-script-map-and-list { flex-direction: column; height: 36rem; }
#earthquakes-maplibre-script-list .maplace-list { flex: 0 0 50%; max-height: 50%; }
}
</style>
<div id="earthquakes-maplibre-script-map-and-list">
<div id="earthquakes-maplibre-script-map"></div>
<div id="earthquakes-maplibre-script-list"></div>
</div>
<script type="module">
// The quakes, each weighing its magnitude, in the group the heatmap draws; the volcanoes, pins.
const [quakes, volcanoes] = await Promise.all([
fetch("/examples/data/earthquakes.json").then((response) => response.json()),
fetch("/examples/data/volcanoes.json").then((response) => response.json()),
]);
Maplace.createMapLibreMap("#earthquakes-maplibre-script-map", {
locations: [...quakes, ...volcanoes],
heatmap: { groups: ["Quakes"] },
view: { kind: "center", center: { lat: 20, lng: 160 }, zoom: 2 },
list: {
container: "#earthquakes-maplibre-script-list",
search: true,
searchLabel: "Find a quake or a volcano",
groupFilter: true,
},
});
</script><!doctype html>
<!-- A page of your own script: the CDN script and what the map and its list mount on, and the map made with Maplace, which adds Maps JS with your key; the quakes as a heatmap by magnitude, the volcanoes as pins. -->
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element.iife.js"></script>
<style>
#earthquakes-script-map-and-list { display: flex; height: 24rem; }
#earthquakes-script-map { flex: 1 1 auto; min-width: 0; }
#earthquakes-script-list { display: contents; }
#earthquakes-script-list .maplace-list { flex: 0 1 16rem; }
/* On a phone the list goes under the map, its half staying that size as the quakes narrow. */
@media (width < 40rem) {
#earthquakes-script-map-and-list { flex-direction: column; height: 36rem; }
#earthquakes-script-list .maplace-list { flex: 0 0 50%; max-height: 50%; }
}
</style>
<div id="earthquakes-script-map-and-list">
<div id="earthquakes-script-map"></div>
<div id="earthquakes-script-list"></div>
</div>
<script type="module">
// The quakes, each weighing its magnitude, in the group the heatmap draws; the volcanoes, pins.
const [quakes, volcanoes] = await Promise.all([
fetch("/examples/data/earthquakes.json").then((response) => response.json()),
fetch("/examples/data/volcanoes.json").then((response) => response.json()),
]);
Maplace.createGoogleMap("#earthquakes-script-map", {
apiKey: "YOUR_KEY",
locations: [...quakes, ...volcanoes],
heatmap: { groups: ["Quakes"] },
view: { kind: "center", center: { lat: 20, lng: 160 }, zoom: 2 },
list: {
container: "#earthquakes-script-list",
search: true,
searchLabel: "Find a quake or a volcano",
groupFilter: true,
},
});
</script><!doctype html>
<!-- The page vanilla.ts runs on: what the map and its list mount on, and the module, which brings maplibre-gl and its stylesheet. -->
<style>
#earthquakes-maplibre-vanilla-map-and-list { display: flex; height: 24rem; }
#earthquakes-maplibre-vanilla-map { flex: 1 1 auto; min-width: 0; }
#earthquakes-maplibre-vanilla-list { display: contents; }
#earthquakes-maplibre-vanilla-list .maplace-list { flex: 0 1 16rem; }
/* On a phone the list goes under the map, its half staying that size as the quakes narrow. */
@media (width < 40rem) {
#earthquakes-maplibre-vanilla-map-and-list { flex-direction: column; height: 36rem; }
#earthquakes-maplibre-vanilla-list .maplace-list { flex: 0 0 50%; max-height: 50%; }
}
</style>
<div id="earthquakes-maplibre-vanilla-map-and-list">
<div id="earthquakes-maplibre-vanilla-map"></div>
<div id="earthquakes-maplibre-vanilla-list"></div>
</div>
<script type="module" src="./vanilla.ts"></script>import "maplibre-gl/dist/maplibre-gl.css";
import type { Location } from "@maplacejs/maplace";
import { createMapLibreMap } from "@maplacejs/maplace/maplibre";
async function fetched(url: string): Promise<Location[]> {
return (await fetch(url)).json();
}
// The quakes, each weighing its magnitude, in the group the heatmap draws; the volcanoes, pins.
const [quakes, volcanoes] = await Promise.all([
fetched("/examples/data/earthquakes.json"),
fetched("/examples/data/volcanoes.json"),
]);
createMapLibreMap("#earthquakes-maplibre-vanilla-map", {
locations: [...quakes, ...volcanoes],
heatmap: { groups: ["Quakes"] },
view: { kind: "center", center: { lat: 20, lng: 160 }, zoom: 2 },
list: {
container: "#earthquakes-maplibre-vanilla-list",
search: true,
searchLabel: "Find a quake or a volcano",
groupFilter: true,
},
});<!doctype html>
<!-- The page vanilla.ts runs on: Maps JS from Google's bootstrap loader, what the module mounts on, the module. -->Google's bootstrap loader, with your API key: from Google's docs
<script>
(g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({
key: "YOUR_KEY",
v: "weekly",
});
</script><style>
#earthquakes-vanilla-map-and-list { display: flex; height: 24rem; }
#earthquakes-vanilla-map { flex: 1 1 auto; min-width: 0; }
#earthquakes-vanilla-list { display: contents; }
#earthquakes-vanilla-list .maplace-list { flex: 0 1 16rem; }
/* On a phone the list goes under the map, its half staying that size as the quakes narrow. */
@media (width < 40rem) {
#earthquakes-vanilla-map-and-list { flex-direction: column; height: 36rem; }
#earthquakes-vanilla-list .maplace-list { flex: 0 0 50%; max-height: 50%; }
}
</style>
<div id="earthquakes-vanilla-map-and-list">
<div id="earthquakes-vanilla-map"></div>
<div id="earthquakes-vanilla-list"></div>
</div>
<script type="module" src="./vanilla.ts"></script>import type { Location } from "@maplacejs/maplace";
import { createGoogleMap } from "@maplacejs/maplace/google";
async function fetched(url: string): Promise<Location[]> {
return (await fetch(url)).json();
}
// The quakes, each weighing its magnitude, in the group the heatmap draws; the volcanoes, pins.
const [quakes, volcanoes] = await Promise.all([
fetched("/examples/data/earthquakes.json"),
fetched("/examples/data/volcanoes.json"),
]);
createGoogleMap("#earthquakes-vanilla-map", {
locations: [...quakes, ...volcanoes],
heatmap: { groups: ["Quakes"] },
view: { kind: "center", center: { lat: 20, lng: 160 }, zoom: 2 },
list: {
container: "#earthquakes-vanilla-list",
search: true,
searchLabel: "Find a quake or a volcano",
groupFilter: true,
},
});<!doctype html>
<!-- The page react.tsx renders into: what the module mounts on, and the module, which brings maplibre-gl and its stylesheet. -->
<style>
#earthquakes-maplibre-react-root .map-and-list { display: flex; height: 24rem; }
#earthquakes-maplibre-react-root .map { flex: 1 1 auto; min-width: 0; }
#earthquakes-maplibre-react-root .maplace-list { flex: 0 1 16rem; }
/* On a phone the list goes under the map, its half staying that size as the quakes narrow. */
@media (width < 40rem) {
#earthquakes-maplibre-react-root .map-and-list { flex-direction: column; height: 36rem; }
#earthquakes-maplibre-react-root .maplace-list { flex: 0 0 50%; max-height: 50%; }
}
</style>
<div id="earthquakes-maplibre-react-root"></div>
<script type="module" src="./react.tsx"></script>import "maplibre-gl/dist/maplibre-gl.css";
import type { Location } from "@maplacejs/maplace";
import { createMapLibreAdapter } from "@maplacejs/maplace/maplibre";
import { LocationList, MaplaceMap, MaplaceProvider } from "@maplacejs/maplace/react";
import { StrictMode, useEffect, useState } from "react";
import { createRoot } from "react-dom/client";
/** The quakes' group is drawn as heat, each quake weighing its magnitude; the volcanoes, pins. */
const HEATMAP = { groups: ["Quakes"] };
const FIRST_VIEW = { kind: "center", center: { lat: 20, lng: 160 }, zoom: 2 } as const;
async function fetched(url: string): Promise<Location[]> {
return (await fetch(url)).json();
}
function Earthquakes() {
const [locations, setLocations] = useState<readonly Location[]>([]);
useEffect(() => {
Promise.all([
fetched("/examples/data/earthquakes.json"),
fetched("/examples/data/volcanoes.json"),
]).then(([quakes, volcanoes]) => setLocations([...quakes, ...volcanoes]));
}, []);
return (
<MaplaceProvider locations={locations} heatmap={HEATMAP} view={FIRST_VIEW}>
<div className="map-and-list">
<MaplaceMap createAdapter={createMapLibreAdapter} className="map" />
<LocationList search searchLabel="Find a quake or a volcano" groupFilter />
</div>
</MaplaceProvider>
);
}
createRoot(document.getElementById("earthquakes-maplibre-react-root") as HTMLElement).render(
<StrictMode>
<Earthquakes />
</StrictMode>,
);<!doctype html>
<!-- The page react.tsx renders into: Maps JS from Google's bootstrap loader, what the module mounts on, the module. -->Google's bootstrap loader, with your API key: from Google's docs
<script>
(g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({
key: "YOUR_KEY",
v: "weekly",
});
</script><style>
#earthquakes-react-root .map-and-list { display: flex; height: 24rem; }
#earthquakes-react-root .map { flex: 1 1 auto; min-width: 0; }
#earthquakes-react-root .maplace-list { flex: 0 1 16rem; }
/* On a phone the list goes under the map, its half staying that size as the quakes narrow. */
@media (width < 40rem) {
#earthquakes-react-root .map-and-list { flex-direction: column; height: 36rem; }
#earthquakes-react-root .maplace-list { flex: 0 0 50%; max-height: 50%; }
}
</style>
<div id="earthquakes-react-root"></div>
<script type="module" src="./react.tsx"></script>import type { Location } from "@maplacejs/maplace";
import { createGoogleAdapter } from "@maplacejs/maplace/google";
import { LocationList, MaplaceMap, MaplaceProvider } from "@maplacejs/maplace/react";
import { StrictMode, useEffect, useState } from "react";
import { createRoot } from "react-dom/client";
/** The quakes' group is drawn as heat, each quake weighing its magnitude; the volcanoes, pins. */
const HEATMAP = { groups: ["Quakes"] };
const FIRST_VIEW = { kind: "center", center: { lat: 20, lng: 160 }, zoom: 2 } as const;
async function fetched(url: string): Promise<Location[]> {
return (await fetch(url)).json();
}
function Earthquakes() {
const [locations, setLocations] = useState<readonly Location[]>([]);
useEffect(() => {
Promise.all([
fetched("/examples/data/earthquakes.json"),
fetched("/examples/data/volcanoes.json"),
]).then(([quakes, volcanoes]) => setLocations([...quakes, ...volcanoes]));
}, []);
return (
<MaplaceProvider locations={locations} heatmap={HEATMAP} view={FIRST_VIEW}>
<div className="map-and-list">
<MaplaceMap createAdapter={createGoogleAdapter} className="map" />
<LocationList search searchLabel="Find a quake or a volcano" groupFilter />
</div>
</MaplaceProvider>
);
}
createRoot(document.getElementById("earthquakes-react-root") as HTMLElement).render(
<StrictMode>
<Earthquakes />
</StrictMode>,
);How it works
A month of earthquakes of magnitude 4.5 and up, drawn as a heatmap weighted by magnitude, with a dozen volcanoes as pins: the quakes are locations as any other, so the list’s search and its checkbox for each group narrow the heat with them.
- The data:
earthquakes.json, a month of the USGS’s earthquakes of magnitude 4.5 and up, to November 2026 (public domain), each with its magnitude asweight;volcanoes.json, a dozen well-known volcanoes. - HTML:
heatmap="Quakes"on<maplace-map>draws the markers of the groupQuakesas heat,group-filteradds a Groups button above the list that opens the checkboxes, andheatmap-max-zoomsets where it gives way to the dots (Map attributes); a quake’sweightis its magnitude. - Script and Bundler:
heatmap: { groups: ["Quakes"] }in the map’s options,maxZoombeside it (Heatmaps),groupFilter: truein itslist, andweighton each quake (Markers). - React: the same
heatmapon<MaplaceProvider>, beside a<LocationList search groupFilter>(<LocationList>). - On both providers: MapLibre draws the heat and the dots in its own layers, under the pins; Google, on a canvas over the map, the dots as markers. A marker in the heat has no
iconand isn’teditable: it is drawn as heat and a dot.