Maplace.js

Clusters and heatmaps

Marker clustering

Markers near each other clustered into one badge counting them, split apart as you zoom in.

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 points-4k.json

<!doctype html>
<script src="https://cdn.jsdelivr.net/npm/@maplacejs/maplace@1/dist/maplace-element-maplibre.iife.js"></script>
<!-- Clustered points from a JSON file, which the element loads from src (the MapLibre build bundles its clustering): the markers near each other drawn as one badge counting them, which splits as you zoom in. -->
<maplace-map id="big-maplibre-map" cluster src="/examples/data/points-4k.json"></maplace-map>

How it works

A large set of points from a JSON file: those near each other are drawn as one badge counting them, so the map stays fast and readable.

  • HTML: cluster on <maplace-map>, on a CDN script that bundles clustering: maplace-element-cluster.iife.js on Google, while MapLibre’s script always does (Map attributes). src names the points’ file, which the element loads, so the page has no script (Data).
  • Script and Bundler: cluster: true in the map’s options, then setLocations with the points (Options). The Script version on Google is on the same cluster script; from npm, each provider loads its clustering only for a map that clusters (on Google, on MapLibre).
  • React: the cluster prop of <MaplaceProvider> (<MaplaceProvider>).
  • Their look: Cluster badges has the badge’s colours, as Brand colours uses them.
  • With a list: a list of every point is too long to use; one that lists only what is in the map’s view is in Search this area.