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.
Ok nevermind, I just saw the answers here:
https://developers.google.com/places/web-service/autocomplete#location_biasing
and
https://developers.google.com/places/web-service/details#PlaceDetailsRequests
@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
Most helpful comment
@edoantonioco try to replace
GooglePlacesDetailsQuery={{ fields: 'formatted_address', }}to
GooglePlacesDetailsQuery={{ fields: 'geometry', }}