9

This question here basically asks the same question:

Restrict Google Places Autocomplete to return addresses only

But doesn't get the right answer.

If we look at the official documentation examples they have an option to selected address type. However, on it, we can see that it will allow us to selected just streets:

enter image description here

Is there a way to make Places Autocomplete select real addresses only?

dwjohnston
  • 11,163
  • 32
  • 99
  • 194

1 Answers1

0

Since this question is quite old, the search result is now somehow different but the fact that address type returns street addresses remains the same.

And to clarify things here, the API is working as intended when it returns street addresses.

types=address seems to be quite vague and what you need to do is to be more specific if you don't want street address to be included.

Here's a table for reference on the different types of restrictions for autocomplete from the Place Types Documentation.

Table 3: Type collections supported in Place Autocomplete requests

The supported types are:

geocode instructs the Place Autocomplete service to return only geocoding results, rather than business results. Generally, you use this request to disambiguate results where the location specified may be indeterminate.

address instructs the Place Autocomplete service to return only geocoding results with a precise address. Generally, you use this request when you know the user will be looking for a fully specified address.

establishment instructs the Place Autocomplete service to return only business results.

(regions) type collection instructs the Places service to return any result matching the following types:

locality sublocality postal_code country administrative_area_level_1 administrative_area_level_2

(cities) type collection instructs the Places service to return results that match locality or administrative_area_level_3.

To further prove this, I tried using the official documentation example for testing.

I tried searching real street address with both types=address and types=geocode and they return street addresses as expected.

With address type:
address type

With geocode type:
geocode type

Then I tried the types=establishment and it did not return any street addresses.

With establishment type:
establishment type

You can use any other types value apart from types=establishment like the (cities) and (regions). As long as you are specific in your restrictions, things will be working fine. You can just put some toggle on your app to change restrictions just like on the official docs example so that your end user could freely choose the restrictions. But it still depends on your use case.

Hope this helps.

Yrll
  • 1,619
  • 2
  • 5
  • 19