Get coordinates (latitude and longitude) from marker in Google Maps

1.9k views Asked by At

I started to use great package react-google-maps. Could you help me how can I get the values of latitude and longitude from inserted (clicked) marker?

If I log returned object I get scope which consist of latitude and longitude.. but I can not access to scopes..

enter image description here

I use something like this example https://tomchentw.github.io/react-google-maps/ with some changes. I want to store in states latitude and longitude from clicked marker.

Thank you.

1

There are 1 answers

1
An Nguyen On BEST ANSWER

I assume that you want to get the list of longitude/latitude from the list of Marker within state. Assuming arr is an array of Marker from google map:

arr.map(x => x.position.lat()) will give you the latitude.

arr.map(x => x.position.long()) will give you the longitude