Heatmap layer (heatmap helper)
This example shows the process of adding a heatmap layer onto the map by using the heatmap layer helper with its default settings. To replicate this example, download the earthquake sample data.
A heatmap map is a visual representation of data values using different colors to indicate their magnitude within a dataset. In certain scenarios, like crime analytics, the color in a heatmap is used to represent the density of data points rather than the specific value associated with each point.
In this particular example, the heatmap layer is designed to compensate for zooming, which means that the size of the blobs remains relatively consistent when we zoom in or out on a global scale. This behavior is the standard default setting.
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: 6.56,
center: [-119.715, 37.999],
style: MapStyle.DATAVIZ.LIGHT
});
map.on('load', async function () {
await helpers.addHeatmap(map, {
data: 'YOUR_MAPTILER_DATASET_ID_HERE',
});
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="robots" content="noindex">
<title>Heatmap layer (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 custom radius by property (heatmap helper)
ExamplesApply property-ramping radius configurations to heatmap layers.
Heatmap layer opacity (heatmap helper)
ExamplesCustomize the opacity of your heatmap layer visualization.