The api for this is the 'types' parameter.
Documented here
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
The api for this is the 'types' parameter.
Documented here https://developers.google./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
Share Improve this question asked Jun 14, 2017 at 3:31 usermaxusermax 1431 silver badge11 bronze badges1 Answer
Reset to default 5Unfortunately, for autoplete, 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 autoplete box. This link can be used for the api: https://maps.googleapis./maps/api/place/autoplete/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
.