MicheleBertoli / react-gmaps

A Google Maps component for React.js

Home Page:http://react-gmaps.herokuapp.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

JosueAshton opened this issue · comments

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__: ƒ () [[FunctionLocation]]: js?callback=mapsCall…BCdYUvYxXVP3KCsg:62 [[Scopes]]: Scopes[3] __proto__: Object pixel: _.P {x: -90, y: -39} ra: undefined wa: undefined __proto__: Object

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.

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