From the angular google maps API, we have a markerClick() function with the following definition,
@Output() markerClick: EventEmitter<void> = new EventEmitter<void>();
But when I am using in my application, I am getting NULL.
I have the following code for the application,
In my HTML file,
<agm-map [latitude]="latitude" [longitude]="longitude" [zoom]="zoom">
<agm-marker *ngFor="let marker of coordinates;"
[iconUrl]="icon"
[latitude]="marker.latitude"
[longitude]="marker.longitude"
[markerClickable]="true"
(markerClick)="markerClicked($event)">
</agm-marker>
</agm-map>
And in .TS file,
markerClicked($event: MouseEvent) {
console.log('clicked'); ----------------(1)
console.log($event);--------------------(2)
}
For statement (2), I am getting NULL as the console output. I am expecting it to be marker Object. Is my understanding wrong? How to get the lat and lng from the markerClick() function.
Note, I am already using mapClick() function for the agm-map tag, but when I am using that function, It is not responding to clicks on already drawn markers on the Map.