Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Places API vs. Google Geocode API

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.

like image 628
Tudor Ravoiu Avatar asked Feb 18 '14 22:02

Tudor Ravoiu


People also ask

What is Google geocode API?

The Geocoding API is a service that provides geocoding and reverse geocoding of addresses. This service is also available as part of the client-side Google Maps JavaScript API, or for server-side use with the Java Client, Python Client, Go Client and Node. js Client for Google Maps Services.

Is Google places an API?

The Places API is a service that returns information about places using HTTP requests. Places are defined within this API as establishments, geographic locations, or prominent points of interest.

What is the difference between Google places and Google Maps?

Google Maps and Google Places API can be primarily classified as "Mapping APIs" tools. According to the StackShare community, Google Maps has a broader approval, being mentioned in 2501 company stacks & 6357 developers stacks; compared to Google Places API, which is listed in 12 company stacks and 5 developer stacks.


2 Answers

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

    like image 59
    Kaushal Shukla Avatar answered Sep 17 '22 19:09

    Kaushal Shukla


    There is no way to achieve it via an Autocomplete.

    When you type in a autocomplete the API first will request the predictions, but not the details.

    This means that at the time when you see the predictions it's still not clear if there are details available for this place.

    There are cases when the particular place can't be found. I'm sure when it would be possible for google to exclude the missing places they wouldn't return them at all.

    The only workaround I see would be to create the autocomplete on your own by requesting both, predictions and details , before you apply the predictions. But note: each time the user types into the input this will count as 6 requests(assuming 5 predictions will be returned)

    like image 28
    Dr.Molle Avatar answered Sep 18 '22 19:09

    Dr.Molle