OmAr Hesham
OmAr Hesham

Reputation: 153

Get the description of the place from its Name

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.

Upvotes: 2

Views: 530

Answers (2)

Nishant Shah
Nishant Shah

Reputation: 3442

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

check this

Upvotes: 1

Leon Lucardie
Leon Lucardie

Reputation: 9730

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.

Upvotes: 2

Related Questions