Hello i m trying to implement google maps in my Angular project , the map is showing fine but i added a function to get the latitude and longitude when the user click on the map but i keep getting the cannot read error
App component :
export class AppComponent {
title = 'PI';
latitude = 51.678418;
longitude = 7.809007;
locationChosen = false;
onChoseLocation(event) {
this.latitude = event.coords.lat;
this.longitude = event.coords.lng;
this.locationChosen = true;}
}
HTML :
<agm-map [latitude]="latitude" [longitude]="longitude" (click)="onChoseLocation($event)">
<agm-marker [latitude]="latitude" [longitude]="longitude" *ngIf="locationChosen"></agm-marker>
</agm-map>