Using Agm mps and i want to get the lat lng on map click in angular 10

1k views Asked by At

Here is my code but it is not working. when I click on the map it displays error: Cannot read property 'lat' of undefined

 <agm-map
          style="height: 700px"
          [latitude]="lat"
          [longitude]="lng"
          [zoom]="zoom"
          (mapClick)="placeMarker($event)"
        >

Ts file


placeMarker($event) {
    console.log($event.coords.lat);
    console.log($event.coords.lng);
  }```
1

There are 1 answers

0
Prakash Harvani On BEST ANSWER

Please Refer to This Example,

https://www.freakyjolly.com/angular-google-maps-using-agm-core/#.X3L25nUzY5k

There is a good Example to understand About AGM Also refer below example

https://stackblitz.com/edit/angular-google-maps-demo?file=app%2Fapp.component.html