React-native-google-places-autocomplete: Getting Latitude and Longitude via OnPress

Created on 1 Mar 2018  路  9Comments  路  Source: FaridSafi/react-native-google-places-autocomplete

Hi,

I was just wondering how can we get the latitude and longitude of places selected via OnPress for this library. If that's not possible here, is there any way?

PS: I already know the JSON response from OnPress doesn't have latitude and longitude with it.

Most helpful comment

@edoantonioco try to replace

GooglePlacesDetailsQuery={{ fields: 'formatted_address', }}

to

GooglePlacesDetailsQuery={{ fields: 'geometry', }}

All 9 comments

@ProteanDev can you share your code, that will be great.

Did you try
onPress={(data, details = null) => {console.warn(details)}} ?

@ProteanDev can you share your code, that will be great.

Try this.

onPress={(data, details = null) => {
// 'details' is provided when fetchDetails = true
console.log(JSON.stringify(details.geometry.location));
}}

@ProteanDev I am able to get JSON response but I want geometry paramter also how can I get that?

@ProteanDev can you share your code, that will be great.

Try this.

onPress={(data, details = null) => {
// 'details' is provided when fetchDetails = true
console.log(JSON.stringify(details.geometry.location));
}}

That geometry is not inside details anymore, is there any reason why?
So there is no way to get coordinates.

@edoantonioco try to replace

GooglePlacesDetailsQuery={{ fields: 'formatted_address', }}

to

GooglePlacesDetailsQuery={{ fields: 'geometry', }}

Thank you @dharam1890

Thank you @dharam1890

Was this page helpful?
0 / 5 - 0 ratings

Related issues

quandevelopment picture quandevelopment  路  4Comments

yashwanth15 picture yashwanth15  路  3Comments

aymkin picture aymkin  路  4Comments

DennisMuchiri picture DennisMuchiri  路  4Comments

sohel-tech picture sohel-tech  路  3Comments