Skip to content

Heatmap Style Layer

The HeatmapStyleLayer is either used by the map style or can be added to the map programmatically to symbolize data on the map.

Heatmap Layer

Basic Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
late final MapController _controller;

@override
Widget build(BuildContext context) {
  return MapLibreMap(
      options: MapOptions(initCamera: .position(center: Geographic(lon: 9.17, lat: 47.68), zoom: 7)),
      onMapCreated: (controller) => _controller = controller,
      onStyleLoaded: (style) async {
        const earthquakes = GeoJsonSource.url(
          id: _sourceId,
          url:
          'https://maplibre.org/maplibre-gl-js/docs/assets/earthquakes.geojson',
        );
        await style.sources.add(earthquakes);
        final layer = HeatmapStyleLayer(id: _layerId, sourceId: _sourceId);
        await style.layers.add(layer);
      }
  );
}

Check out the example app to learn more.

Style & Layout

Every property of the style spec is an optional parameter and a getter and setter of the layer. See Paint & Layout and Expressions.

Read the Paint & Layout chapter to learn more on this topic.