Skip to main content
Docs homeExamplesGitHub
Layers

Aggregation Layers

Examples of deck.gl aggregation and heatmap layers

See Peer Dependencies for the complete list of required packages for each component.

See all interactive examples at mapcn-vue.geoql.in/examples

HeatmapLayer

Live Demo

Visualize point density as a heatmap.

<script setup lang="ts">
  import { VMap } from '@geoql/v-maplibre';
  import { VLayerDeckglHeatmap } from '@geoql/v-maplibre/deck.gl';

  const mapOptions = {
    style: 'https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json',
    center: [-122.4, 37.8],
    zoom: 11,
  };

  const earthquakes = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/examples/screen-grid/ca-earthquakes.json';
</script>

<template>
  <VMap :options="mapOptions" style="height: 500px">
    <VLayerDeckglHeatmap
      id="heatmap"
      :data="earthquakes"
      :get-position="(d) => [d.longitude, d.latitude]"
      :get-weight="(d) => d.magnitude"
      :radius-pixels="30"
      :intensity="1"
      :threshold="0.03"
    />
  </VMap>
</template>

HexagonLayer

Live Demo

Aggregate points into hexagonal bins with optional 3D elevation.

<script setup lang="ts">
  import { VMap } from '@geoql/v-maplibre';
  import { VLayerDeckglHexagon } from '@geoql/v-maplibre/deck.gl';

  const mapOptions = {
    style: 'https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json',
    center: [-122.4, 37.8],
    zoom: 11,
    pitch: 45,
  };

  const points = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/examples/3d-heatmap/heatmap-data.csv';
</script>

<template>
  <VMap :options="mapOptions" style="height: 500px">
    <VLayerDeckglHexagon
      id="hexagons"
      :data="points"
      :get-position="(d) => [Number(d.lng), Number(d.lat)]"
      :radius="200"
      :elevation-scale="4"
      :elevation-range="[0, 1000]"
      :extruded="true"
      :pickable="true"
      :coverage="0.8"
    />
  </VMap>
</template>

GridLayer

Live Demo

Aggregate points into a square grid.

<script setup lang="ts">
  import { VMap } from '@geoql/v-maplibre';
  import { VLayerDeckglGrid } from '@geoql/v-maplibre/deck.gl';

  const mapOptions = {
    style: 'https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json',
    center: [-122.4, 37.8],
    zoom: 11,
    pitch: 45,
  };

  const points = [
    { coordinates: [-122.42, 37.78] },
    { coordinates: [-122.41, 37.79] },
    { coordinates: [-122.43, 37.77] },
  ];
</script>

<template>
  <VMap :options="mapOptions" style="height: 500px">
    <VLayerDeckglGrid
      id="grid"
      :data="points"
      :get-position="(d) => d.coordinates"
      :cell-size="200"
      :elevation-scale="4"
      :extruded="true"
      :pickable="true"
    />
  </VMap>
</template>

ContourLayer

Live Demo

Render contour lines from point data.

<script setup lang="ts">
  import { VMap } from '@geoql/v-maplibre';
  import { VLayerDeckglContour } from '@geoql/v-maplibre/deck.gl';

  const mapOptions = {
    style: 'https://basemaps.cartocdn.com/gl/positron-gl-style/style.json',
    center: [-122.4, 37.8],
    zoom: 11,
  };

  const points = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/examples/screen-grid/ca-earthquakes.json';

  const contours = [
    { threshold: 1, color: [255, 255, 178], strokeWidth: 1 },
    { threshold: 5, color: [254, 204, 92], strokeWidth: 2 },
    { threshold: 10, color: [253, 141, 60], strokeWidth: 3 },
    { threshold: 20, color: [227, 26, 28], strokeWidth: 4 },
  ];
</script>

<template>
  <VMap :options="mapOptions" style="height: 500px">
    <VLayerDeckglContour
      id="contours"
      :data="points"
      :get-position="(d) => [d.longitude, d.latitude]"
      :contours="contours"
      :cell-size="200"
    />
  </VMap>
</template>

ScreenGridLayer

Live Demo

Screen-space grid aggregation with fixed pixel size.

<script setup lang="ts">
  import { VMap } from '@geoql/v-maplibre';
  import { VLayerDeckglScreenGrid } from '@geoql/v-maplibre/deck.gl';

  const mapOptions = {
    style: 'https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json',
    center: [-122.4, 37.8],
    zoom: 11,
  };

  const points = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/examples/screen-grid/ca-earthquakes.json';
</script>

<template>
  <VMap :options="mapOptions" style="height: 500px">
    <VLayerDeckglScreenGrid
      id="screen-grid"
      :data="points"
      :get-position="(d) => [d.longitude, d.latitude]"
      :get-weight="(d) => d.magnitude"
      :cell-size-pixels="20"
      :opacity="0.8"
    />
  </VMap>
</template>