MicheleBertoli / react-gmaps

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

Create onClick for the Map component #91

Closed rodmerritt closed 7 years ago

rodmerritt commented 7 years ago

Is there a way to get long/lat from a click event on the Map component?

endziu commented 7 years ago

of course. something like this should work: <Gmaps onClick={(event)=>console.log('click', event.latLng.lat(), event.latLng.lng())} />

MicheleBertoli commented 7 years ago

Thanks for your answer @endziu, it works exactly like that.

@rodmerritt this package supports all the map events out of the box, and you can attach the handlers using the onEventName pattern. Your handlers will receive the same parameters the Google SDK is passing, for example the click event receives the following parameter: https://developers.google.com/maps/documentation/javascript/3.exp/reference#MouseEvent