Heatmap layer opacity (heatmap helper)

This example demonstrates the process of incorporating a heatmap layer onto the map while customizing its opacity. To accomplish this, the heatmap layer helper is employed. To replicate this example, download the earthquake sample data.

In this particular instance, we modify the layer’s transparency based on the zoom level.

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.8,
    center: [-116.783, 33.5211],
    style: MapStyle.DATAVIZ.DARK
});

map.on('load', async function () {
  await helpers.addHeatmap(map, {
    data: 'YOUR_MAPTILER_DATASET_ID_HERE',
    opacity: [
      {zoom: 3, value: 0 }, // fade in
      {zoom: 4, value: 1 }, // full opacity
      {zoom: 5, value: 0.75 }, // 75% opacity
      {zoom: 8, value: 0.50 }, // 50% opacity
      {zoom: 11, value: 0 }, // fade out
    ],
  });
});
Heatmap layer (heatmap helper)

Heatmap layer (heatmap helper)

Examples

Quickly add a heatmap layer using the heatmap helper.

Create a heatmap layer

Create a heatmap layer

Examples

Visualize point data frequency using a custom heatmap layer.

Heatmap layer min and max zoom (heatmap helper)

Heatmap layer min and max zoom (heatmap helper)

Examples

Set minimum and maximum zoom levels for heatmap layers.

Point layer cluster (point helper)

Point layer cluster (point helper)

Examples

Add clustered point layer using MapTiler point helper.

Was this helpful?