MicheleBertoli / react-gmaps

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

NPM react-gmaps - how to get latitude and logintud when finished dragging a marker? #125

Closed JosueAshton closed 1 year ago

JosueAshton commented 5 years ago

Hi, the function callback gives me zero results

In the render: <Marker lat={this.state.coords.lat} lng={this.state.coords.lng} draggable={true} onDragEnd={(e)=>{console.log(e)}} />

the result per console `onDragEnd .$k {latLng: .R, wa: undefined, pixel: .P, ra: undefined} latLng: .R lat: ƒ () lng: ƒ () arguments: null caller: null length: 0 name: "" prototype: {constructor: ƒ} proto: ƒ ()

proto: Object pixel: _.P {x: -90, y: -39} ra: undefined wa: undefined proto: Object`

michaelmota commented 4 years ago

Hi,

To get the latitude/longitude just to a function callback like:

const onDragEnd = (e) => { console.log(e.latLng.lng(), e.latLng.lat()) } On e.latLng.lng() you'll let longitude, e.latLng.lat() you'll get Latitude.

MicheleBertoli commented 1 year ago

Thanks @JosueAshton for your question, and thanks @michaelmota for answering.