Heatmap layer custom radius by property (heatmap helper)
This example demonstrates the process of incorporating a heatmap layer onto the map by utilizing the heatmap layer helper. It involves adding a custom property-ramping radius to the heatmap layer. To replicate this example, download the US schools sample data.
Additionally, the heatmap layer is internally ramped with zoom values to enhance its functionality.
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: 11.51,
center: [-81.4158, 28.5213],
style: MapStyle.DATAVIZ.LIGHT
});
map.on('load', async function () {
await helpers.addHeatmap(map, {
data: 'schools.geojson',
property: "students",
radius: [
{propertyValue: 500, value: 20},
{propertyValue: 6000, value: 200},
],
});
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="robots" content="noindex">
<title>Heatmap layer custom radius by property (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 weight (heatmap helper)
ExamplesUse data properties as weight values for heatmap layers.