Skip to content

Commit 81aa285

Browse files
committedFeb 25, 2025·
fix(google-maps): resolve mismatching types (#30544)
Due to some infrastructure issues, we can't import the real types for the marker clusterer. We work around it by copying some of them into the repository which has caused an issue where the external types no longer align with the internal ones. This change resolves the issue by converting a few classes to interfaces. Fixes #30466. (cherry picked from commit 2b7133b)
1 parent 69d6bb3 commit 81aa285

File tree

2 files changed

+22
-29
lines changed

2 files changed

+22
-29
lines changed
 

‎src/google-maps/map-marker-clusterer/map-marker-clusterer-types.ts

+9-19
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,15 @@ export interface ClusterOptions {
2020
markers?: Marker[];
2121
}
2222

23-
export declare class Cluster {
23+
export interface Cluster {
2424
marker?: Marker;
2525
readonly markers?: Marker[];
26-
protected _position: google.maps.LatLng;
27-
constructor({markers, position}: ClusterOptions);
28-
get bounds(): google.maps.LatLngBounds | undefined;
29-
get position(): google.maps.LatLng;
30-
/**
31-
* Get the count of **visible** markers.
32-
*/
33-
get count(): number;
34-
/**
35-
* Add a marker to the cluster.
36-
*/
26+
bounds?: google.maps.LatLngBounds;
27+
position: google.maps.LatLng;
28+
count: number;
3729
push(marker: Marker): void;
38-
/**
39-
* Cleanup references and remove marker from map.
40-
*/
4130
delete(): void;
31+
new (options: ClusterOptions): Cluster;
4232
}
4333

4434
export declare class MarkerClusterer extends google.maps.OverlayView {
@@ -117,11 +107,11 @@ export interface Renderer {
117107
render(cluster: Cluster, stats: ClusterStats, map: google.maps.Map): Marker;
118108
}
119109

120-
export declare class ClusterStats {
121-
readonly markers: {
110+
export interface ClusterStats {
111+
markers: {
122112
sum: number;
123113
};
124-
readonly clusters: {
114+
clusters: {
125115
count: number;
126116
markers: {
127117
mean: number;
@@ -130,7 +120,7 @@ export declare class ClusterStats {
130120
max: number;
131121
};
132122
};
133-
constructor(markers: Marker[], clusters: Cluster[]);
123+
new (markers: Marker[], clusters: Cluster[]): ClusterStats;
134124
}
135125

136126
export interface Algorithm {

‎tools/public_api_guard/google-maps/google-maps.md

+13-10
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,22 @@ export type AriaLabelFn = (text: string) => string;
4949
export type Calculator = (markers: google.maps.Marker[], clusterIconStylesCount: number) => ClusterIconInfo;
5050

5151
// @public (undocumented)
52-
export class Cluster {
53-
constructor({ markers, position }: ClusterOptions);
52+
export interface Cluster {
53+
// (undocumented)
54+
new (options: ClusterOptions): Cluster;
55+
// (undocumented)
56+
bounds?: google.maps.LatLngBounds;
57+
// (undocumented)
58+
count: number;
5459
// (undocumented)
55-
get bounds(): google.maps.LatLngBounds | undefined;
56-
get count(): number;
5760
delete(): void;
5861
// (undocumented)
5962
marker?: Marker;
6063
// (undocumented)
6164
readonly markers?: Marker[];
6265
// (undocumented)
63-
get position(): google.maps.LatLng;
66+
position: google.maps.LatLng;
6467
// (undocumented)
65-
protected _position: google.maps.LatLng;
6668
push(marker: Marker): void;
6769
}
6870

@@ -107,10 +109,11 @@ export interface ClusterOptions {
107109
}
108110

109111
// @public (undocumented)
110-
export class ClusterStats {
111-
constructor(markers: Marker[], clusters: Cluster[]);
112+
export interface ClusterStats {
113+
// (undocumented)
114+
new (markers: Marker[], clusters: Cluster[]): ClusterStats;
112115
// (undocumented)
113-
readonly clusters: {
116+
clusters: {
114117
count: number;
115118
markers: {
116119
mean: number;
@@ -120,7 +123,7 @@ export class ClusterStats {
120123
};
121124
};
122125
// (undocumented)
123-
readonly markers: {
126+
markers: {
124127
sum: number;
125128
};
126129
}

0 commit comments

Comments
 (0)
Please sign in to comment.