Maplace.js

Clusters and heatmaps

Heatmaps

A month of earthquakes as a heatmap by magnitude, dots when zoomed in, volcanoes as pins, a checkbox for each.

Markdown

Map and code

Run the examples on

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>

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 as weight; volcanoes.json, a dozen well-known volcanoes.
  • HTML: heatmap="Quakes" on <maplace-map> draws the markers of the group Quakes as heat, group-filter adds a Groups button above the list that opens the checkboxes, and heatmap-max-zoom sets where it gives way to the dots (Map attributes); a quake’s weight is its magnitude.
  • Script and Bundler: heatmap: { groups: ["Quakes"] } in the map’s options, maxZoom beside it (Heatmaps), groupFilter: true in its list, and weight on each quake (Markers).
  • React: the same heatmap on <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 icon and isn’t editable: it is drawn as heat and a dot.