xkjyeah / vue-google-maps

Google maps component for vue with 2-way data binding
https://xkjyeah.github.io/vue-google-maps/
1.88k stars 475 forks source link

How to get address info from latLng, on Marker>DragEnd #86

Open ghost opened 7 years ago

danpetban commented 7 years ago

When you call your function in your template like this: @dragend="functionName"

You simply check the passed $event object like:

functionName (place) {
  console.log('lat: ' + place.latLng.lat)
  console.log('lng: ' + place.latLng.lgn) 
}
norotico commented 7 years ago

By "address info" he means postal code, street name and such, not the lat/lgn coordinates.

I'm after that too. Does vue-google-maps expose the geocode functionality?

xkjyeah commented 7 years ago

Nope, not directly. On drag end, get the new position of the lat long, pass that into the directions API, and wait for a result.

On 8 May 2017 02:03, "norotico" notifications@github.com wrote:

By "address info" he means postal code, street name and such, not the lat/lgn coordinates.

I'm after this too. Does vue-google-maps expose a method for that?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/xkjyeah/vue-google-maps/issues/86#issuecomment-299723318, or mute the thread https://github.com/notifications/unsubscribe-auth/ACiTR5WXDy7xZ1hArzr97YuZg-2ausK-ks5r3gdggaJpZM4M29Ok .

raymayemir commented 6 years ago

@xkjyeah @band94 why dragend event return data like lat: function (){return a} lng: function (){return b} ???

murcoder commented 6 years ago

I've got the same issue:

lat: function (){return a}

I want to save the coordinates (lang,lat) to the database. How to get the coordinates?

@raymayemir EDIT: Just found out: You have to call it as a funtion!

functionName (place) {
  console.log('lat: ' + place.latLng.lat() )
  console.log('lng: ' + place.latLng.lgn() ) 
}