Multiple Markers with Click Event in Google Map Cordova

Hello everyone !

I have a little project which i want to show the map with many markers and every marker can be clicked.
I just complete add markers by the useful tutorial on Google Map Cordova site. But i don’t know how to add the click event to each marker.

This is my script to add markers

            addMarkers(data, function (markers) {
                markers[markers.length - 1].showInfoWindow();
            });
            function addMarkers(data, callback) {
                var markers = [];
                function onMarkerAdded(marker) {
                    markers.push(marker);
                    if (markers.length === data.length) {
                        callback(markers);
                    }
                    marker.addEventListener(GoogleMapsEvent.INFO_CLICK, () => {
                        alert('fukc');
                    })
                }

                data.forEach((element) => {
                    map.addMarker({
                        'position': new GoogleMapsLatLng(element.location.lat, element.location.lng),
                        'title': element.title,
                        'snippet' : 'Đến điểm bán này',
                    }).then(onMarkerAdded);

                });
                
            }

Anyone can help me :frowning:

in the doc or somewhere, I saw this, here you go:

map.addMarker({
    'position': new GoogleMapsLatLng(element.location.lat, element.location.lng),
    'title': element.title,
    'snippet' : 'Đến điểm bán này',
    'markerClick': function(marker) {
        console.log(marker.get('snippet'));
    }
}).then(onMarkerAdded);

…I was looking for how to do callbacks after you add a marker…thanks for demonstrating that with .then()