React-google-maps: Get latitude longitude of a place on map click

Created on 4 Jul 2018  ·  2Comments  ·  Source: tomchentw/react-google-maps

Getting Help

Before doing this, did you:

  1. Read the documentation
  2. Read the source code

_You can get someone's help in three ways_:

  1. Ask on StackOverflow with a google-maps tag or use react-google-maps as a keyword
  2. Ask in the chat room
  3. Create a Pull Request with your solutions to your problem

Please, be noted, no one, I mean, no one, is obligated to help you in ANY means. Your time is valuable, so does our contributors. Don't waste our time posting questions like “how do I do X with React-Google-Maps” and “my code doesn't work”. This is not the primary purpose of the issue tracker. Don't abuse.

Most helpful comment

@shameersam You can get lat, lng by add onClick to props in GoogleMap

<GoogleMap  onClick={this.handleClickedMap }  />

handleClickedMap = (e) => {
   let latitude = e.latLng.lat()
   let longtitude  = e.latLng.lat()
   console.log(lat, lng)
}

I hope it useful.

All 2 comments

How to get latitude and longitude of a place on click in map

@shameersam You can get lat, lng by add onClick to props in GoogleMap

<GoogleMap  onClick={this.handleClickedMap }  />

handleClickedMap = (e) => {
   let latitude = e.latLng.lat()
   let longtitude  = e.latLng.lat()
   console.log(lat, lng)
}

I hope it useful.

Was this page helpful?
0 / 5 - 0 ratings