Skip to content

Heatmap (gm-heatmap)


The Heatmap is a great way to show fuzzy data in a colorful way.

Simple Use (demo)

html
<template>
  <div style="height: 500px">
    <gm-map>
      <gm-heatmap :data="dataPoints" :radius="20" :opacity="0.8" />
    </gm-map>
  </div>
</template>

<script setup lang="ts">
import { gmMap, gmHeatmap, type GmWeightedPosition } from 'v3-gmaps';

const dataPoints: GmWeightedPosition[] = [
  { lat: 37, lng: 56, weight: 3 },
  { lat: 15, lng: 108, weight: 1 },
  // ...more items
];
</script>

Props

PropsTypeDefaultDescription
dataGmWeightedPosition[]-Sets the Heatmap data points.
radiusnumber-The radius of influence for each data point, in pixels.
opacitynumber-The opacity of the heatmap, from 0 to 1.
gradientstring[]-The color gradient of the heatmap, as an array of CSS colors.
dissipatingbooleantrueWhether heatmap dissipates on zoom.
maxIntensitynumber-The maximum intensity of the heatmap.

Events

EventTypeDescription
mountedgoogle.maps.visualization.HeatmapLayerOn mounted the component will emit the Google Maps object it represents.
unmountedgoogle.maps.visualization.HeatmapLayerOn unmounted the component will emit the Google Maps object it represents.

Notes

  • While regular position objects ({ lat, lng }) can be used, the Heatmap can also use weighted points: { lat, lng, weight } which can add an extra dimension to your data.
  • The gradient colors array should start with transparent for the lowest intensity and end with your highest intensity color.

Released under the MIT License.