Reputation: 143
The api for this is the 'types' parameter.
Documented here https://developers.google.com/places/supported_types#table3
Ideally I'd pass ['administrative_area_level_1','country'] but it doesn't show any results.
Passing only one of these types doesn't show any results either.
The best match is ['(regions)'], but besides countries and states, it finds city names as well, which are irrelevant in my use case.
How can this be solved?
Thanks
Upvotes: 3
Views: 6432
Reputation: 697
Unfortunately, for autocomplete, only the geocode
, address
, establishment
, (regions)
, and (cities)
types can be used.
The only way this problem can really be solved is by using the HTTP API and creating your own UI for the autocomplete box. This link can be used for the api: https://maps.googleapis.com/maps/api/place/autocomplete/json?input=QUERY&key=API_KEY&types=(regions)
. The result is returned in a JSON object, and each item has a types
field consisting of an array of the types applicable to the location. The type at index 0 is the one you're interested in. It's usually something like country
, or administrative_area_level_1
.
Upvotes: 5