HeatmapLayer component renders a heatmap visualization on the map, showing data point density using color gradients.
Import
Requirements
The visualization library must be loaded to use the heatmap layer:Props
data
google.maps.MVCArray<google.maps.LatLng | google.maps.visualization.WeightedLocation> | google.maps.LatLng[] | google.maps.visualization.WeightedLocation[]
required
The data points to display in the heatmap. Can be an array or MVCArray of LatLng coordinates or WeightedLocation objects.Required: This prop is mandatory for the heatmap layer to function.
Configuration options for the heatmap layer appearance and behavior.Common options include:
dissipating: Whether the heatmap dissipates at higher zoom levelsgradient: Array of colors for the gradientmaxIntensity: Maximum intensity of the heatmapopacity: Opacity of the heatmap (0-1)radius: Radius of influence for each data point
Callback invoked when the heatmap layer instance is loaded and ready.Parameters:
heatmapLayer: The Google Maps HeatmapLayer instance
Callback invoked when the heatmap layer is unmounted and removed from the map.Parameters:
heatmapLayer: The Google Maps HeatmapLayer instance being unmounted
Component Variants
This component is available in two variants:HeatmapLayer- The default memoized componentHeatmapLayerF- The functional component variant (same implementation)
Usage Example
Weighted Locations Example
Notes
- The
dataprop is required and the component will throw an error if not provided - The visualization library must be included in the
librariesarray when loading the API - The component returns
nulland does not render any DOM elements - The heatmap layer is automatically removed when the component unmounts
- Use weighted locations to emphasize certain data points more than others