Skip to content

Incorrect type on ClusterClickCallbackData #92

Description

@adriallongarriu

Bug Report

Plugin(s)

7.0.3

Capacitor Version

Image

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

setOnClusterClickListener(callback?: MapListenerCallback<ClusterClickCallbackData>): Promise<void>;
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...

Image

Expected Behavior

Regardless of the platform, the functions work the same.

Code Reproduction

await this.googleMap.setOnClusterClickListener(async (event) => {
      console.log(event)    
});

Other Technical Details

Additional Context

What i have done to solve this:

    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.

await this.googleMap.setOnCameraIdleListener((event) => {
      this.currentZoom = event.zoom;
});

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions