How can i add a click event to my markers?
I already try this:
markers[i].on('GoogleMapsEvent.MARKER_CLICK').subscribe(() => {
});
but i get this error:
markers[i].on is not a function ; Zone: <root> ; Task: Promise.then ; Value: TypeError: markers[i].on is not a function
My marker objects is this:
__zone_symbol__state:true
__zone_symbol__value:undefined
proto:Object
is right? i added to my markers arrays when this happens:
for (let i = 0; i < locations.length; i++) {
let latlng: LatLng = new LatLng(locations[i].lat, locations[i].lng);
let markerOptions: MarkerOptions = {
position: latlng,
title: locations[i].id
};
const marker: Marker = map.addMarker(markerOptions)
.then((marker: Marker) => {
});
//HERE I ADD MY MARKER TO MARKERS IS OKAY?
this.markers.push(marker);
}
resolve(this.markers);
Also i try:
markers[i].addListener('click', function () {
});
But i get:
markers[i].addListener is not a function ; Zone: <root> ; Task: Promise.then ; Value: TypeError: markers[i].addListener is not a function