Sarsaparilla
Sarsaparilla

Reputation: 6690

How to handle mixed Google Places queries that contain both place name and location?

I need to develop a Point of Interest search application. I would like to allow users to enter queries like "Starbucks in San Diego" or "San Diego Starbucks". I'm able to do this on map.google.com, but I'm not sure if any such heuristic capability is provided by the Google Maps API.

I'm already using Google Places to look for places within a specific area. And I can use Geocoding API to locate addresses on the map.

Is this possible at all with the current API? Any suggestion for doing this?

Upvotes: 0

Views: 202

Answers (1)

Chris Green
Chris Green

Reputation: 4425

I would recommend using the Google Places Autocomplete API to perform a request with the input parameter as "San Diego Starbucks", this will return a list of predictions:

https://maps.googleapis.com/maps/api/place/autocomplete/json?input=San%20Diego%20Starbucks&sensor=false&key=your_api_key

You can then use the returned reference parameter from a prediction to perform a Place Details Request which will provide you with more information about the selected place, including address and geographical location:

https://maps.googleapis.com/maps/api/place/details/json?reference=ClREAAAA2UwUUGS85fmru6jzwcSS6fcaMgPItqqLPB-cyTTJm6dMSX0IPmpHAqUR6JWiWoZWrtk6sPI_TJzlfoHma4m0kk3VAoDMu21gebdIdtaMnscSEDDjFLZ5iCC-W1iiAvbZM3caFJuU7TIwS6vj9T77wk24BfpeObSB&sensor=true&key=you_api_key

Upvotes: 1

Related Questions