I use URL:
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=bar&key=API_KEY&types=geocode
What should I do to retrieve data with places location (Latitude and Longitude)?
Getting latitude and longitude Wen the user has selected a place we can get the latitude and longitude by calling lat() and lng() on the place object.
You could use place. geometry. location. lat() and place.
It is not possible ONLY with this URL:
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=bar&key=API_KEY
All I needed to do was to get place_id
from response, and then use it in NEXT following URL:
https://maps.googleapis.com/maps/api/place/details/json?input=bar&placeid=PLACE_ID&key=API_KEY
Where:
PLACE_ID - retrieved place_id
from previous request.
API_KEY - my key generated by Google to use with my app.
autocomplete
must be replaced with details
in above URL's.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With