danielsogl / awesome-cordova-plugins

Native features for mobile apps built with Cordova/PhoneGap and open web technologies. Complete with TypeScript support.
https://danielsogl.gitbook.io/awesome-cordova-plugins/
Other
2.41k stars 2.42k forks source link

MarkerCluster : Bad arguments for MARKER_CLICK event #1935

Closed Flo-D closed 7 years ago

Flo-D commented 7 years ago

Hello, first of all I want to thank @wf9a5m75 for the time he spent on the MarkerCluster functionnality !

I'm submitting a ... (check one with "x") [x ] bug report [ ] feature request

Current behavior:

The Observable returned when listening to MARKER_CLICK event on a MarkerCluster only contains the position (LatLng), not the marker reference

Expected behavior:

We should be able to get the marker reference when clicking on one in a MarkerCluster, in order to use it to open an InfoWindow for example

Steps to reproduce:

Add a MarkerCluster to a map and try to set a listener on it for the MARKER_CLICK event with 2 arguments in return

Related code:

markerCluster.on(GoogleMapsEvent.MARKER_CLICK).subscribe((position, marker) => {
   console.log('marker clicked');
});

When building with this code, I get the following error :

Argument of type '(position: any, marker: any) => void' is not assignable to parameter of type '(value: any) => void'.

Other information:

It is noticed in the doc at the bottom of this page :

Event Arguments
MARKER_CLICK Arguments: LatLng, Marker
This event is fired when you click on a marker.

And shown in the demo here :

markerCluster.on(plugin.google.maps.event.MARKER_CLICK, function (position, marker) {
   //code
});

package.json info:

{
    "name": "ionic-hello-world",
    "version": "0.0.0",
    "author": "Ionic Framework",
    "homepage": "http://ionicframework.com/",
    "private": true,
    "scripts": {
        "clean": "ionic-app-scripts clean",
        "build": "ionic-app-scripts build",
        "lint": "ionic-app-scripts lint",
        "ionic:build": "ionic-app-scripts build",
        "ionic:serve": "ionic-app-scripts serve"
    },
    "dependencies": {
        "@angular/common": "4.1.3",
        "@angular/compiler": "4.1.3",
        "@angular/compiler-cli": "4.1.3",
        "@angular/core": "4.1.3",
        "@angular/forms": "4.1.3",
        "@angular/http": "4.1.3",
        "@angular/platform-browser": "4.1.3",
        "@angular/platform-browser-dynamic": "4.1.3",
        "@ionic-native/app-version": "^4.1.0",
        "@ionic-native/camera": "^4.1.0",
        "@ionic-native/core": "3.12.1",
        "@ionic-native/crop": "^4.1.0",
        "@ionic-native/google-maps": "^4.2.1",
        "@ionic-native/network": "^4.1.0",
        "@ionic-native/splash-screen": "3.12.1",
        "@ionic-native/status-bar": "3.12.1",
        "@ionic/storage": "2.0.1",
        "cordova-android": "^6.2.3",
        "cordova-ios": "^4.4.0",
        "cordova-plugin-app-version": "^0.1.9",
        "cordova-plugin-camera": "^2.4.1",
        "cordova-plugin-compat": "^1.1.0",
        "cordova-plugin-console": "1.0.5",
        "cordova-plugin-crop": "^0.4.0",
        "cordova-plugin-device": "1.1.4",
        "cordova-plugin-googlemaps": "git+https://github.com/mapsplugin/cordova-plugin-googlemaps.git#multiple_maps",
        "cordova-plugin-googlemaps-sdk": "git+https://github.com/mapsplugin/cordova-plugin-googlemaps-sdk.git",
        "cordova-plugin-network-information": "^1.3.3",
        "cordova-plugin-splashscreen": "~4.0.1",
        "cordova-plugin-statusbar": "2.2.2",
        "cordova-plugin-whitelist": "1.3.1",
        "ionic-angular": "3.6.0",
        "ionic-plugin-keyboard": "~2.2.1",
        "ionicons": "3.0.0",
        "rxjs": "5.4.0",
        "sw-toolbox": "3.6.0",
        "zone.js": "0.8.12"
    },
    "devDependencies": {
        "@ionic/app-scripts": "2.1.3",
        "typescript": "2.3.4"
    },
    "cordovaPlugins": [
        "cordova-plugin-whitelist",
        "cordova-plugin-statusbar",
        "cordova-plugin-console",
        "cordova-plugin-device",
        "cordova-plugin-splashscreen",
        "ionic-plugin-keyboard"
    ],
    "cordovaPlatforms": [],
    "description": "HCM_App: An Ionic project",
    "cordova": {
        "plugins": {
            "cordova-plugin-console": {},
            "cordova-plugin-device": {},
            "cordova-plugin-splashscreen": {},
            "cordova-plugin-statusbar": {},
            "cordova-plugin-whitelist": {},
            "ionic-plugin-keyboard": {},
            "cordova-plugin-network-information": {},
            "cordova-plugin-app-version": {},
            "cordova-plugin-camera": {
                "CAMERA_USAGE_DESCRIPTION": " ",
                "PHOTOLIBRARY_USAGE_DESCRIPTION": " "
            },
            "cordova-plugin-crop": {},
            "cordova-plugin-googlemaps": {
                "API_KEY_FOR_ANDROID": "androidKey",
                "API_KEY_FOR_IOS": "iosKey",
                "LOCATION_WHEN_IN_USE_DESCRIPTION": "Show your location on the map",
                "LOCATION_ALWAYS_USAGE_DESCRIPTION": "Trace your location on the map"
            }
        },
        "platforms": [
            "android",
            "ios"
        ]
    }
}

Thank you in advance

wf9a5m75 commented 7 years ago

The doc page is for pure JavaScript. Not for the ionic wrapper plugin

Flo-D commented 7 years ago

Sure, I saw it, that's why I posted the issue here in the ionic-native repo. But the Ionic wrapper plugin should allow us to get the marker reference in the same way, otherwise we can't add a click listener on markers which are in a cluster.

wf9a5m75 commented 7 years ago

Because of the restriction of RxJs, the wrapper plugin can not pass multiple arguments to the callback. That's why the wrapper plugin passes multiple values as array to the first argument. Did you confirm with console.log()?

Flo-D commented 7 years ago

Unfortunately it is not an array for the click event. I've just checked with this code :

this.markerCluster.on(GoogleMapsEvent.MARKER_CLICK).subscribe(value => {
   console.log(value);
}

And when clicking on a marker I got a LatLng object :

LatLng {lat: -31.950827, lng: 115.834576}
wf9a5m75 commented 7 years ago

Okay, I will check it later. And might need help @ihadeed

wf9a5m75 commented 7 years ago

By the way, did you update @ionic-native/core also?

Flo-D commented 7 years ago

Ok thank you !

Yes I updated the plugin and even ionic-native wrapper

cordova-plugin-googlemaps 2.0.0-beta3-20170829-1218 "cordova-plugin-googlemaps"
wf9a5m75 commented 7 years ago

Opps, \@ is disappeared ...

I mean did you also update @ ionic-native/core plugin?

wf9a5m75 commented 7 years ago

Oh, you did (you listed in the description).

wf9a5m75 commented 7 years ago

I worked with this code.

issue_1935

import {Component} from "@angular/core";
import {IonicPage, NavController, NavParams} from "ionic-angular";
import {
  GoogleMaps,
  GoogleMap,
  GoogleMapsEvent,
  MarkerCluster,
  LatLng,
  GoogleMapsAnimation,
  Marker
} from "@ionic-native/google-maps";

/**
 * Generated class for the AddMarkerClusterPage page.
 *
 * See http://ionicframework.com/docs/components/#navigation for more info
 * on Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-add-marker-cluster',
  templateUrl: 'add-marker-cluster.html',
})
export class AddMarkerClusterPage {
  map: GoogleMap;

  constructor(public navCtrl: NavController, public navParams: NavParams, private googleMaps: GoogleMaps) {
  }

  ionViewDidLoad() {
    setTimeout(this.loadMap.bind(this), 1000);
  }

  loadMap() {
    let self = this;

    this.map = this.googleMaps.create('map_canvas', {
      'camera': {
        'target': {
          "lat": 21.382314,
          "lng": -157.933097
        },
        'zoom': 10
      }
    });

    this.map.one(GoogleMapsEvent.MAP_READY).then(() => {
      self.addCluster(self.dummyData());
    });
  }

  addCluster(data) {
    this.map.addMarkerCluster({
      boundsDraw: false,
      maxZoomLevel: 12,
      markers: data,
      icons: [
        {
          min: 3,
          url: "./assets/large.png",
          anchor: { x: 16, y: 16 },
          size: {
            width: 37,
            height: 37
          }
        }
      ]
    }).then((markerCluster: MarkerCluster) => {

      markerCluster.on(GoogleMapsEvent.MARKER_CLICK).subscribe((params) => {
        let latLng: LatLng = params[0];
        let marker: Marker = params[1];

        marker.setAnimation(GoogleMapsAnimation.BOUNCE);
      });

    });
  }

  dummyData() {
    return [
      {
        "position": {
          "lat": 21.382314,
          "lng": -157.933097
        },
        "name": "Starbucks - HI - Aiea  03641",
        "address": "Aiea Shopping Center_99-115 Aiea Heights Drive #125_Aiea, Hawaii 96701",
        "phone": "808-484-1488",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.3871,
          "lng": -157.9482
        },
        "name": "Starbucks - HI - Aiea  03642",
        "address": "Pearlridge Center_98-125 Kaonohi Street_Aiea, Hawaii 96701",
        "phone": "808-484-9548",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.363402,
          "lng": -157.928275
        },
        "name": "Starbucks - HI - Aiea  03643",
        "address": "Stadium Marketplace_4561 Salt Lake Boulevard_Aiea, Hawaii 96818",
        "phone": "808-488-9313",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.3884,
          "lng": -157.9431
        },
        "name": "Starbucks - HI - Aiea  03644",
        "address": "Pearlridge Mall_98-1005 Moanalua Road_Aiea, Hawaii 96701",
        "phone": "808-484-9355",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.6507,
          "lng": -158.0652
        },
        "name": "Starbucks - HI - Haleiwa  03645",
        "address": "Pupukea_59-720 Kamehameha Highway_Haleiwa, Hawaii 96712",
        "phone": "808-638-0341",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 19.699335,
          "lng": -155.06566
        },
        "name": "Starbucks - HI - Hilo  03646",
        "address": "Border Waiakea Center_315-325 Makaala Street_Hilo, Hawaii 96720",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 19.698399,
          "lng": -155.064864
        },
        "name": "Starbucks - HI - Hilo  03647",
        "address": "Prince Kuhio Plaza_111 East Puainako Street_Hilo, Hawaii 96720",
        "phone": "808-959-2492",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 19.722763,
          "lng": -155.085598
        },
        "name": "Starbucks - HI - Hilo [D]  03648",
        "address": "Hilo_438 Kilauea Ave_Hilo, Hawaii 96720",
        "phone": "808-933-3094",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.338183,
          "lng": -157.917579
        },
        "name": "Starbucks - HI - Honolulu  03649",
        "address": "Airport Trade Center_550 Paiea Street_Honolulu, Hawaii 96819",
        "phone": "808-833-3519",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.3074,
          "lng": -157.865199
        },
        "name": "Starbucks - HI - Honolulu  03650",
        "address": "Aloha Tower_1 Aloha Tower Drive_Honolulu, Hawaii 96813",
        "phone": "808-522-1901",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.30846253,
          "lng": -157.8614898
        },
        "name": "Starbucks - HI - Honolulu  03651",
        "address": "Bishop_1000 Bishop Street #104_Honolulu, Hawaii 96813",
        "phone": "808-599-4833",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.311363,
          "lng": -157.863751
        },
        "name": "Starbucks - HI - Honolulu  03652",
        "address": "Central Pacific Bank_220 South King Street_Honolulu, Hawaii 96813",
        "phone": "808-538-7600",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.28507546,
          "lng": -157.838214
        },
        "name": "Starbucks - HI - Honolulu  03653",
        "address": "Discovery Bay_1778 Ala Moana Boulevard_Honolulu, Hawaii 96815",
        "phone": "808-946-8563",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.342733,
          "lng": -158.027408
        },
        "name": "Starbucks - HI - Honolulu  03654",
        "address": "Ewa Beach_91-1401 Fort Weaver Road_Honolulu, Hawaii 96706",
        "phone": "808-685-4594",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.28005068,
          "lng": -157.8285093
        },
        "name": "Starbucks - HI - Honolulu  03655",
        "address": "Duty Free Shopper_330 Royal Hawaiian Avenue_Honolulu, Hawaii 96815",
        "phone": "808-926-4863",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.3115,
          "lng": -157.8649
        },
        "name": "Starbucks - HI - Honolulu  03656",
        "address": "Financial Plaza_130 Merchant Street #111_Honolulu, Hawaii 96813",
        "phone": "808-585-8658",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.282048,
          "lng": -157.713041
        },
        "name": "Starbucks - HI - Honolulu  03657",
        "address": "Hawaii Kai Town Center_6700 Kalanianaole Highway_Honolulu, Hawaii 96825",
        "phone": "808-396-3013",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.291345,
          "lng": -157.848791
        },
        "name": "Starbucks - HI - Honolulu  03658",
        "address": "Hokua_1288 Ala Moana Blvd_Honolulu, Hawaii 96814",
        "phone": "808-591-2891",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.335164,
          "lng": -157.868742
        },
        "name": "Starbucks - HI - Honolulu  03659",
        "address": "Kamehameha Shopping Center_1620 North School Street_Honolulu, Hawaii 96817",
        "phone": "808-832-1430",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.27852422,
          "lng": -157.7875773
        },
        "name": "Starbucks - HI - Honolulu  03660",
        "address": "Kahala Mall_4211 Waialae Avenue_Honolulu, Hawaii 96816",
        "phone": "808-737-0283",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.294372,
          "lng": -157.841963
        },
        "name": "Starbucks - HI - Honolulu  03661",
        "address": "Keeaumoku_678 Keeamoku Street #106_Honolulu, Hawaii 96814",
        "phone": "808-946-7513",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.2819,
          "lng": -157.8163
        },
        "name": "Starbucks - HI - Honolulu  03662",
        "address": "Kapahulu Avenue_625 Kapahulu Avenue_Honolulu, Hawaii 96815",
        "phone": "808-734-4116",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.27608195,
          "lng": -157.7049835
        },
        "name": "Starbucks - HI - Honolulu  03663",
        "address": "Koko Marina_7192 Kalanianaole Highway_Honolulu, Hawaii 96825",
        "phone": "808-394-5577",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.3129,
          "lng": -157.8129
        },
        "name": "Starbucks - HI - Honolulu  03664",
        "address": "Manoa Valley_2902 East Manoa Road_Honolulu, Hawaii 96822",
        "phone": "808-988-9295",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.293082,
          "lng": -157.847092
        },
        "name": "Starbucks - HI - Honolulu  03665",
        "address": "Macys Ala Moana_1450 Ala Moan Boulevard_Honolulu, Hawaii 96814",
        "phone": "808-943-2437",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.341957,
          "lng": -157.929089
        },
        "name": "Starbucks - HI - Honolulu  03666",
        "address": "Moanalua Shopping Center_930 Valkenburgh Street_Honolulu, Hawaii 96818",
        "phone": "808-422-2804",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.279503,
          "lng": -157.833101
        },
        "name": "Starbucks - HI - Honolulu  03667",
        "address": "Outrigger Reef_2169 Kalia Road #102_Honolulu, Hawaii 96815",
        "phone": "808-922-8694",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.282251,
          "lng": -157.828172
        },
        "name": "Starbucks - HI - Honolulu  03668",
        "address": "Ohana Waikiki West_2330 Kuhio Avenue_Honolulu, Hawaii 96815",
        "phone": "808-922-9570",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.323602,
          "lng": -157.890904
        },
        "name": "Starbucks - HI - Honolulu  03669",
        "address": "Sand Island_120 Sand Island Access Road #4_Honolulu, Hawaii 96819",
        "phone": "808-832-9915",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.270016,
          "lng": -157.82381
        },
        "name": "Starbucks - HI - Honolulu  03670",
        "address": "Park Shore Hotel_2856 Kalakaua Avenue_Honolulu, Hawaii 96815",
        "phone": "808-923-5726",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.289497,
          "lng": -157.842832
        },
        "name": "Starbucks - HI - Honolulu  03671",
        "address": "Sears Ala Moana Center_1450 Ala Moana Blvd._Honolulu, Hawaii 96814",
        "phone": "808-943-2416",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.28201,
          "lng": -157.831087
        },
        "name": "Starbucks - HI - Honolulu  03672",
        "address": "Waikiki Shopping Plaza_2270 Kalakaua Avenue #1800_Honolulu, Hawaii 96815",
        "phone": "808-922-3901",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.2833,
          "lng": -157.8298
        },
        "name": "Starbucks - HI - Honolulu  03673",
        "address": "Waikiki Trade Center_2255 Kuhio Avenue S-1_Honolulu, Hawaii 96815",
        "phone": "808-921-2190",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.297,
          "lng": -157.8555
        },
        "name": "Starbucks - HI - Honolulu  03674",
        "address": "Ward Entertainment Center_310 Kamakee Street #6_Honolulu, Hawaii 96814",
        "phone": "808-593-1945",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.406095,
          "lng": -157.800761
        },
        "name": "Starbucks - HI - Honolulu  03675",
        "address": "Windward City Shopping Center_45-480 Kaneohe Bay Drive_Honolulu, Hawaii 96744",
        "phone": "808-234-6900",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.2829,
          "lng": -157.8318
        },
        "name": "Starbucks - HI - Honolulu  03676",
        "address": "Waikiki Walk_2222 Kalakaua Avenue_Honolulu, Hawaii 96815",
        "phone": "808-926-3433",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.293045,
          "lng": -157.852223
        },
        "name": "Starbucks - HI - Honolulu  03677",
        "address": "Ward Gateway_1142 Auahi Street_Honolulu, Hawaii 96814",
        "phone": "808-589-2012",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.3067,
          "lng": -157.858444
        },
        "name": "Starbucks - HI - Honolulu [A]  03678",
        "address": "HNL Honolulu Airport_300 Rogers Blvd_Honolulu, Hawaii 96820",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 20.891963,
          "lng": -156.477614
        },
        "name": "Starbucks - HI - Kahului  03679",
        "address": "Queen Kaahumanu Center_275 West Kaahuman Avenue #1200 F5_Kahului, Hawaii 96732",
        "phone": "808-871-2690",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 20.8843,
          "lng": -156.4583
        },
        "name": "Starbucks - HI - Kahului  03680",
        "address": "Maui Marketplace_270 Dairy Road_Kahului, Hawaii 96732",
        "phone": "808-871-7884",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.39356972,
          "lng": -157.7403334
        },
        "name": "Starbucks - HI - Kailua  03681",
        "address": "Kailua Village_539 Kailua Road_Kailua, Hawaii 96734",
        "phone": "808-263-9548",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 19.6512,
          "lng": -155.9944
        },
        "name": "Starbucks - HI - Kailua-Kona  03682",
        "address": "Kona Coast Shopping Center_74-5588 Palani Road_Kailua-Kona, Hawaii 96740",
        "phone": "808-329-1166",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 19.8434,
          "lng": -155.7652
        },
        "name": "Starbucks - HI - Kamuela  03683",
        "address": "Parker Ranch Center_67-1185 Mamalahoa Highway D108_Kamuela, Hawaii 96743",
        "phone": "808-887-6409",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.34306,
          "lng": -158.078906
        },
        "name": "Starbucks - HI - Kapolei  03684",
        "address": "Halekuai Center_563 Farrington Highway #101_Kapolei, Hawaii 96707",
        "phone": "808-674-8735",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.336,
          "lng": -158.0802
        },
        "name": "Starbucks - HI - Kapolei [D]  03685",
        "address": "Kapolei Parkway_338 Kamokila Boulevard #108_Kapolei, Hawaii 96797",
        "phone": "808-674-1941",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 20.740343,
          "lng": -156.456218
        },
        "name": "Starbucks - HI - Kihei  03686",
        "address": "Kukui Mall_1819 South Kihei Road_Kihei, Hawaii 96738",
        "phone": "808-891-0903",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 20.7575,
          "lng": -156.4559
        },
        "name": "Starbucks - HI - Kihei  03687",
        "address": "Piilani Village Shopping Center_247 Piikea Avenue #106_Kihei, Hawaii 96753",
        "phone": "808-891-0755",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 19.9338,
          "lng": -155.8422
        },
        "name": "Starbucks - HI - Kohala Coast  03688",
        "address": "Mauna Lani_68-1330 Mauna Lani Drive H-101b_Kohala Coast, Hawaii 96743",
        "phone": "808-885-0570",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 20.886244,
          "lng": -156.684697
        },
        "name": "Starbucks - HI - Lahaina  03689",
        "address": "Lahaina Cannery Mall_1221 Honoapiilani Highway_Lahaina, Hawaii 96761",
        "phone": "808-661-0865",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 20.8804,
          "lng": -156.6816
        },
        "name": "Starbucks - HI - Lahaina  03690",
        "address": "Lahaina_845 Wainee Street_Lahaina, Hawaii 96761",
        "phone": "808-667-6974",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.970661,
          "lng": -159.396274
        },
        "name": "Starbucks - HI - Lihue  03691",
        "address": "Kukui Grove_3-2600 Kaumualii Highway #A8_Lihue, Hawaii 96766",
        "phone": "808-241-7034",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 20.8818,
          "lng": -156.4633
        },
        "name": "Starbucks - HI - Maui [A]  03692",
        "address": "OGG Kahului Main Concourse_New Terminal Bldg @ Bldg 340_Maui, Hawaii 96732",
        "phone": "808-877-5858",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.4585,
          "lng": -158.0178
        },
        "name": "Starbucks - HI - Mililani  03693",
        "address": "Mililani Shopping Center_95-221 Kipapa Drive_Mililani, Hawaii 96789",
        "phone": "808-625-5401",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.474341,
          "lng": -158.001864
        },
        "name": "Starbucks - HI - Mililani  03694",
        "address": "Mililani Town Center_95-1249 Meheula Parkway_Mililani, Hawaii 96789",
        "phone": "808-627-1846",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 20.838965,
          "lng": -156.34192
        },
        "name": "Starbucks - HI - Pukalani  03695",
        "address": "Pukalani Foodland_55 Pukalani Street_Pukalani, Hawaii 96768",
        "phone": "808-573-5458",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.378675,
          "lng": -157.728499
        },
        "name": "Starbucks - HI - Waipahu  03696",
        "address": "Enchanted Lakes_1020 Keolu Drive_Waipahu, Hawaii 96734",
        "phone": "808-263-3061",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.39662113,
          "lng": -158.0317397
        },
        "name": "Starbucks - HI - Waipahu  03697",
        "address": "Kunia Shopping Center_94-673 Kupuohi Street_Waipahu, Hawaii 96797",
        "phone": "808-680-9221",
        "icon": "./assets/marker.png"
      },
      {
        "position": {
          "lat": 21.403688,
          "lng": -158.006128
        },
        "name": "Starbucks - HI - Waipahu  03698",
        "address": "Waikele_94-799 Lumiaina Street_Waipahu, Hawaii 96797",
        "phone": "808-678-3418",
        "icon": "./assets/marker.png"
      }
    ];
  }

}
wf9a5m75 commented 7 years ago

Ah, you are code is this, but

this.markerCluster.on(GoogleMapsEvent.MARKER_CLICK).subscribe(value => {
   console.log(value);
}

you need to write with parenthesis

this.markerCluster.on(GoogleMapsEvent.MARKER_CLICK).subscribe((value) => {
   console.log(value);
}
Flo-D commented 7 years ago

Okay so I tested your code, I copied/pasted it in my project and it didn't work.

First thing I want to notice is that I got this error :

Argument of type '{ boundsDraw: false; maxZoomLevel: number; markers: any; icons: { min: number; max:
            number; url: ...' is not assignable to parameter of type 'MarkerClusterOptions'. Types of property 'icons'
            are incompatible. Type '{ min: number; max: number; url: string; anchor: { x: number; y: number; }; size: {
            width: number...' is not assignable to type 'MarkerClusterIcon[]'. Type '{ min: number; max: number; url:
            string; anchor: { x: number; y: number; }; size: { width: number...' is not assignable to type
            'MarkerClusterIcon'. Object literal may only specify known properties, and 'size' does not exist in type
            'MarkerClusterIcon'.

So I removed the size attribute to build it successfully. But the marker reference is still missing... When I do a console.log of params[0] and params[1] both are undefined :

markerCluster.on(GoogleMapsEvent.MARKER_CLICK).subscribe((params) => {
        let latLng: LatLng = params[0];
        let marker: Marker = params[1];

        console.log(params);
        console.log(latLng);
        console.log(marker);

        marker.setAnimation(GoogleMapsAnimation.BOUNCE);
});
LatLng {lat: 21.6507, lng: -158.0652}
undefined
undefined
Uncaught TypeError: Cannot read property 'setAnimation' of undefined

To be sure, I created a whole new project (so that all plugins are up-to-date), inserted your code and it gave me the exact same result...

wf9a5m75 commented 7 years ago

please share your created project on github.

Flo-D commented 7 years ago

Sure, you can find it here : https://github.com/Flo-D/test-google-maps-cluster

wf9a5m75 commented 7 years ago

Thank you. And could you show me the screen capture of the output of these lines?

        console.log(params);
        console.log(latLng);
        console.log(marker);

And are you testing on Android or iOS, what version do the use?

Flo-D commented 7 years ago

I'm testing on Android version, here is the capture of what I got in the console :

sans titre

wf9a5m75 commented 7 years ago

Thank you. I mean I asked what version of Android do you use? Could you tell me?

Flo-D commented 7 years ago

Oh sorry, I tested on a real device under Lollipop (5.0.1) and on an emulator under Nougat (7.0)

Flo-D commented 7 years ago

Hi @wf9a5m75, hope you're doing well. Did you have time to get a check on this ? There's a new issue in the cordova-plugin-googlemaps repo, I think it's related to mine : here

wf9a5m75 commented 7 years ago

I tested your project again.

When I built your project, I got the same error as you. However, if I reinstall the @ ionic-native/core and @ ionic-native/google-maps, your code work perfectly. It means the package modules you install are old.

I noticed you specify version 3.12.1 for @ ionic-native/core. But the current @ ionic-native/google-maps requires version 4.12.1 or higher.

screen shot 2017-09-05 at 10 20 07 am

Flo-D commented 7 years ago

Indeed, I've just updated the @ionic-native/core package and it works... As I created a whole new project I thought that the latests versions of all packages would be installed.

I'm so sorry about that and hope you didn't spend too much time on it.

Thank you !

srawit commented 6 years ago

Hello, I have this problem same together but i use "@ionic-native/core": "^4.4.0 and cordova-plugin-googlemaps": "^2.2.4"

and i alert in function but nothing happens.

"markerCluster.on(GoogleMapsEvent.MARKER_CLICK).subscribe((params) => { alert('Click'); });"

Hope you can help me. Thank You.

francoro commented 6 years ago

Same code and doesnt alert but it do a console log from the plugin, this one: -----> This is remained cluster icon : 209105 markerCluster.on(GoogleMapsEvent.MARKER_CLICK).subscribe((params) => { alert('Click'); });

"@ionic-native/core": "4.3.2",
 "@ionic-native/google-maps": "^4.5.3",
cordova-plugin-googlemaps 2.2.5 "cordova-plugin-googlemaps"
wf9a5m75 commented 6 years ago

"@ionic-native/core": "4.5.3"

francoro commented 6 years ago

I update the ionic-native/core to the version you said but still cannot enter de click marker event

darolpz commented 5 years ago

Sorry @wf9a5m75 for bring back the post but I have the same issue with @ionic-native/core@4.20.0 and@ ionic-native/google-maps@4.15.1.Also, if I use the latest version (@Ionic-native/google-maps@4.21.0) the console shows me "Uncaught TypeError: Cannot read property 'indexOf' of undefined" when I click a Marker

Edit: I resolve this degrading the version of @Ionic-native/google-maps to 14.0.0

My code: let clusterOptions: MarkerClusterOptions = { markers: markers, icons: this.clusterIcons }; let markerCluster = this.map.addMarkerClusterSync(clusterOptions); markerCluster.on(GoogleMapsEvent.MARKER_CLICK).subscribe((params: any[]) => { console.log("Marker cluster clicked: " + JSON.stringify(params)); console.log(JSON.stringify(params[1])); }); My dependencies: "dependencies": { "@agm/core": "^1.0.0-beta.5", "@angular/common": "5.2.7", "@angular/compiler": "5.2.7", "@angular/compiler-cli": "5.2.7", "@angular/core": "5.2.7", "@angular/forms": "5.2.7", "@angular/http": "5.2.7", "@angular/platform-browser": "5.2.7", "@angular/platform-browser-dynamic": "5.2.7", "@ionic-native/camera": "^4.19.0", "@ionic-native/core": "^4.20.0", "@ionic-native/device": "4.10.0", "@ionic-native/diagnostic": "^4.20.0", "@ionic-native/file": "^4.20.0", "@ionic-native/firebase": "^4.20.0", "@ionic-native/geolocation": "^4.20.0", "@ionic-native/google-maps": "^4.15.1", "@ionic-native/http": "^4.19.0", "@ionic-native/keyboard": "4.10.0", "@ionic-native/location-accuracy": "^4.20.0", "@ionic-native/native-geocoder": "^5.0.0", "@ionic-native/native-storage": "^4.19.0", "@ionic-native/pro": "4.10.0", "@ionic-native/screen-orientation": "^4.20.0", "@ionic-native/splash-screen": "4.10.0", "@ionic-native/status-bar": "4.10.0", "@ionic/pro": "1.0.20", "@ionic/storage": "^2.1.3", "@types/jquery": "^3.3.29", "cordova-android": "7.1.4", "cordova-browser": "5.0.4", "cordova-ios": "^4.5.4", "cordova-plugin-actionsheet": "2.3.3", "cordova-plugin-advanced-http": "^2.0.4", "cordova-plugin-camera": "^4.0.3", "cordova-plugin-console": "^1.1.0", "cordova-plugin-datepicker": "0.9.3", "cordova-plugin-device": "^1.1.7", "cordova-plugin-dialogs": "2.0.1", "cordova-plugin-file": "^6.0.1", "cordova-plugin-firebase": "2.0.5", "cordova-plugin-geolocation": "^4.0.1", "cordova-plugin-googlemaps": "^2.4.6", "cordova-plugin-nativegeocoder": "^3.1.3", "cordova-plugin-nativestorage": "^2.3.2", "cordova-plugin-request-location-accuracy": "^2.2.3", "cordova-plugin-screen-orientation": "3.0.1", "cordova-plugin-splashscreen": "^4.1.0", "cordova-plugin-statusbar": "^2.4.2", "cordova-plugin-whitelist": "^1.3.3", "cordova-sqlite-storage": "^2.6.0", "cordova.plugins.diagnostic": "^4.0.10", "device": "0.3.9", "devices": "0.1.0", "es6-promise-plugin": "4.2.2", "ion2-calendar": "^2.1.7", "ionic-angular": "3.9.2", "ionic-plugin-keyboard": "^2.2.1", "ionic2-auto-complete": "^1.6.2-alpha", "ionicons": "4.2.4", "jquery": "^3.3.1", "moment": "^2.22.1", "node-sass": "^4.11.0", "rxjs": "^6.0.0", "rxjs-compat": "^6.4.0", "sw-toolbox": "3.6.0", "zone.js": "0.8.18" },