ionic-team / ionic-team/capacitor-google-maps
Incorrect type on ClusterClickCallbackData
- Dominant language
- TypeScript
- Stars
- 32
- Forks
- 47
- PR merge metrics
- No merged PRs in 30d
Description
## Bug Report
### Plugin(s)
7.0.3
### Capacitor Version
### Platform(s)
Web
### Current Behavior
I wanted to get the current lat and lng on click a marker cluster and do zoom.
The function setOnClusterClickListener returna ClusterClickCallbackData and indicates that it latitude is a number
```js
setOnClusterClickListener(callback?: MapListenerCallback): Promise;
```
```js
export interface ClusterClickCallbackData {
mapId: string;
latitude: number;
longitude: number;
size: number;
items: MarkerCallbackData[];
}
```
On Android this works but on web latitude and longitude is returning a function. And if i call a function on Android brakes...
### Expected Behavior
Regardless of the platform, the functions work the same.
### Code Reproduction
```js
await this.googleMap.setOnClusterClickListener(async (event) => {
console.log(event)
});
```
### Other Technical Details
### Additional Context
What i have done to solve this:
```js
await this.googleMap.setOnClusterClickListener(async (event: any) => {
let lat = event.latitude;
let lng = event.longitude;
if (typeof lat === 'function') {
lat = lat();
}
if (typeof lng === 'function') {
lng = lng();
}
if (this.currentZoom < 21) {
await this.googleMap.setCamera({
coordinate: { lat: lat, lng: lng },
zoom: ++this.currentZoom,
animate: true,
});
}
});
```
Note: in case anyone is wondering where it comes from this.currentZoom.
```js
await this.googleMap.setOnCameraIdleListener((event) => {
this.currentZoom = event.zoom;
});
```
Contributor guide
Assessment
This issue has not been assessed yet.