Google Places API vs. Google Geocode API

Tudor Ravoiu picture Tudor Ravoiu · Feb 18, 2014 · Viewed 9.5k times · Source

I have implemented Google Places API with autocomplete and Google Geocoding Api. The problem is that it seems that the results do not work correctly.

Sometimes some of the choosen results from the autocomplete list do not geocode at all, all i get is the status ZERO_RESULTS.

I know that there could be some problems regarding the fact that Google Autocomplete uses also Places, while Google Geocode uses only postal codes, but how could i limit autocomplete to give me only postal codes results.

Answer

Kaushal Shukla picture Kaushal Shukla · Apr 8, 2014

Place Types

You may restrict results from a Place Autocomplete request to be of a certain type by passing a types parameter. The parameter specifies a type or a type collection, as listed in the supported types below. If nothing is specified, all types are returned. In general only a single type is allowed. The exception is that you can safely mix the geocode and establishment types, but note that this will have the same effect as specifying no types. The supported types are:

geocode

instructs the Place Autocomplete service to return only geocoding (address) results. Generally, you use this request to disambiguate results where the location specified may be indeterminate.

establishment instructs the Place Autocomplete service to return only business results. the (regions) type collection instructs the Places service to return any result matching the following types:

  • locality
  • sublocality
  • postal_code
  • country
  • administrative_area1
  • administrative_area2
  • the (cities) type collection instructs the Places service to return results that match either locality or administrative_area3.

    Hope this helps https://developers.google.com/places/documentation/autocomplete