Reputation: 28951
I want to use Google place autocomplete webservice: https://developers.google.com/places/web-service/autocomplete
to search for locations based upon a query (e.g. "High Street"). I also want the latitude and longitude of each place.
It seems that the only way to do this using the web service is to:
Perform an autocomplete search e.g.
Loop through each result and do a separate query for each location (see https://developers.google.com/places/web-service/details):
https://maps.googleapis.com/maps/api/place/details/json?placeid=PLACE_ID&key=YOUR_API_KEY
That means if I have 10 results, I have to do 10 additional web requests! That means 11 in total (1 for autocomplete, and 10 more for each place request).
This is very inefficient!
Surely there is a better way than this, as Google Maps on Android shows the distance of each place to your current location, indicating that the latitude and longitude is returned as shown by this screenshot:
Upvotes: 2
Views: 1852
Reputation: 1425
you can use this API of google APIs https://maps.googleapis.com/maps/api/geocode/json?address=Winnetka&key=YOUR_API_KEY
Upvotes: 0
Reputation: 426
Yes, for Places API, Directions API and Geocoding API that is the case. There is no other way.
Upvotes: 2