Skip to content

Commit 2c9682d

Browse files
committed
fix(googlemaps): accept mixed LatLng | WeightedLocation array in HeatmapLayer.setData
According to the Google Maps API docs, `HeatmapLayer.setData` accepts either a mixed `MVCArray<LatLng | WeightedLocation>` or a native mixed array of `LatLng` and `WeightedLocation`, however the current typings only allow a mixed `MVCArray` or a `LatLng[]` or `WeightedLocation[]`. These changes align the type to the one in the docs. I've also replaced the `any` in `HeatmapLayerOptions.data` with the correct type. More information: https://developers.google.com/maps/documentation/javascript/reference/visualization#HeatmapLayer.setData
1 parent 8cf251b commit 2c9682d

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

types/googlemaps/googlemaps-tests.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,12 @@ heatmap.setData([
418418
{ weight: 2, location: new google.maps.LatLng({ lat: 37.782745, lng: -122.444586 }) },
419419
]);
420420

421+
// setData Should Accept (LatLng | WeightedLocation)[]
422+
heatmap.setData([
423+
new google.maps.LatLng(37.782551, -122.445368),
424+
{ weight: 2, location: new google.maps.LatLng({ lat: 37.782745, lng: -122.444586 }) },
425+
]);
426+
421427
// setOptions should required data and accepted any HeatmapLayerOptions
422428
heatmap.setOptions({
423429
data: [

types/googlemaps/reference/visualization.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ declare namespace google.maps.visualization {
33
constructor(opts?: HeatmapLayerOptions);
44
getData(): MVCArray<LatLng | WeightedLocation>;
55
getMap(): Map;
6-
setData(data: MVCArray<LatLng | WeightedLocation> | LatLng[] | WeightedLocation[]): void;
6+
setData(data: MVCArray<LatLng | WeightedLocation> | Array<LatLng | WeightedLocation>): void;
77
setMap(map: Map | null): void;
88
setOptions(options: HeatmapLayerOptions): void;
99
}
1010

1111
interface HeatmapLayerOptions {
12-
data: any;
12+
data: MVCArray<LatLng | WeightedLocation> | Array<LatLng | WeightedLocation>;
1313
dissipating?: boolean;
1414
gradient?: string[];
1515
map?: Map;

0 commit comments

Comments
 (0)