A tiny and fast heatmap layer plugin for Leaflet.
This repository is Linkurious’ maintained fork of the original Leaflet/Leaflet.heat. The goal of this fork is to keep the same plugin behavior/API while modernizing the codebase and the packaging for today’s JavaScript tooling.
Compared to the original Leaflet/Leaflet.heat, this fork:
- is written in TypeScript (with bundled
.d.tstypes) - ships ESM and CommonJS/UMD-compatible builds via the
exportsmap - uses a Vite-based build/test toolchain
- is published to npm as
@linkurious/leaflet-heat - is intended to be tree-shake friendly when consumed as ESM
If you need the historical 0.2.0-era sources and changelog, refer to the upstream repository.
npm install @linkurious/leaflet-heatimport L from "leaflet";
import { heatLayer } from "@linkurious/leaflet-heat";
const map = L.map("map").setView([0, 0], 2);
L.tileLayer("https://tile.openstreetmap.org/{z}/{x}/{y}.png", {
attribution:
'© <a href="https://osm.org/copyright">OpenStreetMap</a> contributors',
}).addTo(map);
const points: Array<[number, number, number?]> = [
[50.5, 30.5, 0.8],
[50.6, 30.4, 0.5],
[50.3, 30.6, 0.2],
];
heatLayer(points, { radius: 25 }).addTo(map);Creates a heatmap layer given an array of points and an optional options object.
An array of [lat, lng, intensity] or [lat, lng] arrays.
intensity(optional) should be a number between0and1.
| Option | Type | Default | Description |
|---|---|---|---|
| radius | number | 25 | The radius of each "point" of the heatmap. |
| blur | number | 15 | The amount of blur. |
| maxZoom | number | 10 | The maximum zoom level up to which the heatmap should be rendered. |
| max | number | 1.0 | The maximum intensity of the heatmap. |
| gradient | object | null | Color gradient config. |
| minOpacity | number | 0.05 | The minimum opacity the heat will start at. |
| useLocalExtrema | boolean | false | Whether to use the local extremes of the data. |
npm install
npm test
npm run build
# Demo
npm run demo:dev
npm run demo:build
npm run demo:previewThis project is dual-licensed:
- The original Leaflet.heat code (up to version 0.2.0) is licensed under the MIT License (see upstream: https://github.com/Leaflet/Leaflet.heat/blob/master/LICENSE).
- All changes and improvements made by Linkurious are licensed under the Apache 2.0 License (see LICENSE).