Reputation: 715
Implemented the Places Web Service API
- Place Autocomplete https://developers.google.com/places/web-service/autocomplete and works fine, but it doesn't return the Latitude and Longitude of theses places predicted!
That is the request!
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Amoeba&types=geocode&location=37.76999,-122.44696&radius=500®ions=locality&key=KEY
Upvotes: 0
Views: 882
Reputation: 32178
This is an intended behavior. According to the documentation the autocomplete response doesn't contain any location information:
https://developers.google.com/places/web-service/autocomplete#place_autocomplete_results
You have the place ID in the response, so you can execute either place details or geocoding request to get the location for the given place.
For example, in your request the first prediction has a place ID ChIJjxz0JSktaE0RJio-PNWLd60, so you can execute the following request to get coordinates:
https://maps.googleapis.com/maps/api/geocode/json?place_id=ChIJjxz0JSktaE0RJio-PNWLd60&key=YOUR_API_KEY
The response will contain required information
"geometry":{
"bounds":{
"northeast":{
"lat":50.0903542,"lng":-86.29135079999999
},
"southwest":{
"lat":50.0850891,"lng":-86.3070178
}
},
"location":{
"lat":50.0890102,"lng":-86.2987103
},
....
I can also see that the feature request was filed in Google issue tracker, but Google rejected it and marked as Infeasible:
https://issuetracker.google.com/issues/35827993
Upvotes: 1