The HeatmapLayer component is used to depict the intensity of data at geographical points on the map.
⚠️ Critical Deprecation Warning
The Heatmap Layer was removed from the Maps JavaScript API as of version 3.65. To use this component, you must pin the API to version 3.64 or earlier using the version prop on the GoogleMap component.
Google recommends migrating to a third-party integration like deck.gl for heatmap implementations, as version 3.64 will eventually stop resolving.
Requirements
- Pin API Version: Set
version="3.64" on the GoogleMap component. - Include Library: Add
'visualization' to the libraries prop of the GoogleMap component.
<script setup>
import { GoogleMap, HeatmapLayer } from 'vue3-google-map'
const sanFrancisco = { lat: 37.774546, lng: -122.433523 }
const heatmapData = [
{ location: { lat: 37.782, lng: -122.447 }, weight: 0.5 },
{ lat: 37.782, lng: -122.445 },
{ location: { lat: 37.782, lng: -122.443 }, weight: 2 },
{ lat: 37.782, lng: -122.441 }, weight: 3 },
{ lat: 37.782, lng: -122.439 }, weight: 2 },
{ lat: 37.782, lng: -122.437 },
{ location: { lat: 37.782, lng: -122.435 }, weight: 0.5 },
{ location: { lat: 37.785, lng: -122.447 }, weight: 3 },
{ location: { lat: 37.785, lng: -122.445 }, weight: 2 },
{ lat: 37.785, lng: -122.443 },
{ location: { lat: 37.785, lng: -122.441 }, weight: 0.5 },
{ lat: 37.785, lng: -122.439 },
{ location: { lat: 37.785, lng: -122.437 }, weight: 2 },
{ location: { lat: 37.785, lng: -122.435 }, weight: 3 },
]
</script>
<template>
<GoogleMap
api-key="YOUR_GOOGLE_MAPS_API_KEY"
version="3.64"
:libraries="['visualization']"
style="width: 100%; height: 500px"
:center="sanFrancisco"
:zoom="13"
>
<HeatmapLayer :options="{ data: heatmapData }" />
</GoogleMap>
</template>