MicheleBertoli / react-gmaps

A Google Maps component for React.js
http://react-gmaps.herokuapp.com/
MIT License
317 stars 68 forks source link

Get lat and long with pointer #104

Closed ChuchoJuarez closed 7 years ago

ChuchoJuarez commented 7 years ago

Hi I want to know if it is possible to get the coordinates with the pointer.

regards

MicheleBertoli commented 7 years ago

Hello @ChuchoJuarez, can you please explain what you are trying to do in more details? I'm not sure what you mean by "with pointer". Thanks!

copperstick6 commented 7 years ago

Hey @ChuchoJuarez, I'm assuming you want to get the coordinates of the user clicks. Below is a sample code snippet that would allow you to get the latitude and longitude of the user's click:

class Map extends Component{
onClick(e){
    var latLong = [e.latLng.lat(), e.latLng.lng()];
    console.log(latLong);
}
render(){
   return(
   <GMaps
    //insert params here
    onClick = {this.onClick}
   </GMaps>
   );
}
}
ChuchoJuarez commented 7 years ago

Thanks!!!!! @copperstick6 this is just what I needed