Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Places Autocomplete API 'types' parameter only works with establishment?

I am trying to use Google Place's Autocomplete API in my app but am having an issue filtering the results to specific types (i.e. restaurant).

Anytime I change the types parameter to something other than establishment, I get an INVALID_REQUEST response.

However, when I do a standard search of all restaurants nearby, the results that show up match the same autocomplete results.

Example: Applebee's at 555 Saratoga Avenue, San Jose, CA shows up in my nearby search and my autocomplete search, but only has the type establishment in the autocomplete API response while it has restaurant in the standard search API response.

Anyone else encounter this issue or know of a workaround? The API Docs make it sound like all valid types should be acceptable in the autocomplete API request.

Here is my URL using type=restaurant which always fails:

https://maps.googleapis.com/maps/api/place/autocomplete/json?types=restaurant&input=applebee&radius=48280.2&rankby=distance&key=MY_API_KEY&location=37.33233141,-122.0312186

Here is the URL using type=establishment that works:

https://maps.googleapis.com/maps/api/place/autocomplete/json?types=establishment&input=applebee&radius=48280.2&rankby=distance&key= MY_API_KEY&location=37.33233141,-122.0312186
like image 870
JimmyJammed Avatar asked Mar 22 '17 03:03

JimmyJammed


2 Answers

The types you can use for autocomplete is more restricted than those that you can use for search. "restaurant" isn't a valid place type for autocomplete. The valid types are:

  • geocode
  • establishment
  • address
  • (regions)
  • (cities)

See Place Types in the docs for more info.

like image 153
AndrewR Avatar answered Nov 16 '22 01:11

AndrewR


Yes the restaurant type parameter not work in /place/autocomplete/json

if you want to find "restaurant" place/textsearch/json?

search text after add +

Example 1 :

https://maps.googleapis.com/maps/api/place/textsearch/json?query=restaurant+applebee&key={API_KEY}

Example 2 :

https://maps.googleapis.com/maps/api/place/radarsearch/json?location=48.859294,2.347589&radius=5000&type=cafe&keyword=vegetarian&key=YOUR_API_KEY

for multiple type use types=food|restaurant

for more information https://developers.google.com/places/web-service/search

like image 24
Harshil Kotecha Avatar answered Nov 16 '22 00:11

Harshil Kotecha