Heatmap layer intensity (heatmap helper)
This example shows how to add a heatmap layer with a custom intensity to the map using the heatmap layer helper. Download the earthquake sample data to replicate this example.
In this example, we use a custom intensity zoom ramping higher than the default to add some boost to the heatmap’s impact.
NPM module setup
npm install --save @maptiler/sdk
import { Map, MapStyle, config, helpers } from '@maptiler/sdk';
import '@maptiler/sdk/dist/maptiler-sdk.css';
config.apiKey = 'YOUR_MAPTILER_API_KEY_HERE';
const map = new Map({
container: 'map',
zoom: 8.33,
center: [-116.715, 33.542],
style: MapStyle.DATAVIZ.LIGHT
});
map.on('load', async function () {
await helpers.addHeatmap(map, {
data: 'YOUR_MAPTILER_DATASET_ID_HERE',
intensity: [
{zoom: 5, value: 1},
{zoom: 12, value: 5},
]
});
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="robots" content="noindex">
<title>Heatmap layer intensity (heatmap helper) | NPM example</title>
<link rel="stylesheet" href="./style.css">
</head>
<body>
<div id="map"></div>
<script type="module" src="./main.js"></script>
</body>
</html>
body {margin: 0; padding: 0;}
#map {position: absolute; top: 0; bottom: 0; width: 100%;}
Related examples
Heatmap layer radius and weight by property (heatmap helper)
ExamplesControl heatmap radius and weight using data properties.