Question

I am having a small issue here. In my application, the user enters the name of a place, and I should then show him the list of places having the name of the place he entered. so obviously I need to send the entered name to Google Places and I will expect it to return to me a list of descriptions to uniquely identify each place. so is there a way to get this? P.S: I searched alot, and I didn't find how to get the description of a place from its name. Thanks alot.

Was it helpful?

Solution

The default API call to search for a list of locations based on a text query:

https://maps.googleapis.com/maps/api/place/textsearch/json?query=PLACE_NAME&sensor=false&key=YOUR_GOOGLE_API_KEY

This will return a JSON array containing all the locations Google Places found based on what you entered at the PLACE_NAME field each containing some basic information.

If you want a more detailed description you can call:

https://maps.googleapis.com/maps/api/place/details/json?reference=REFERENCE_OF_PLACE&sensor=false&key=YOUR_GOOGLE_API_KEY

Where REFERENCE_OF_PLACE is the reference id (retrieved in the textsearch call) of the place you want to aquire information of.

A google api key can be retrieved by registering at the Google API Console

And example how to retrieve and parse JSON can be found here.

OTHER TIPS

Android provides Geocoder class through which you can get the details of Locations.

check this

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top