Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getPlacePredictions vs getPredictions, google maps autocomplete service clarification

What is the difference between autocompleteService.getPlacePredictions and autocompleteService.getPredictions in the Google Maps Autocomplete Service? I've created tests for these here, but they seem to be returning the same things:

https://github.com/QuantumInformation/google-places-tests

like image 397
Nikos Avatar asked Nov 10 '15 16:11

Nikos


People also ask

Is Google Places Autocomplete free?

The autocomplete request is available at no charge, and the subsequent Place Details call gets charged based on regular Place Details pricing. A Place Details request generates Data SKUs (Basic, Contact, and/or Atmosphere) – depending on the fields that are specified in the request.

Where is Googlecom Autocomplete API key?

You need to go your project. 1: Activate Google places API depending upon your clients: iOS, Android or web. 2: Then go to the Credentials section on the left. 3: Generate a SERVER key.

What are predictions in the places autocomplete service?

When the Places Autocomplete service returns results from a search, it places them within a predictions array. Each prediction result contains the following fields (check here for more details): description, place_id, terms, types, matched_substrings, structured_formatting

How to optimize Google Places autocomplete?

To optimize Google Places Autocomplete, we recommend the following guidelines: Prefer using the AutocompleteService instead of the Widgets to gain fine-grained control over the available optimizations. Use the Per Session billing option. Gather only required fields when getting details of a place. Implement Debounce and minChars mechanisms.

What is the use of autocompleteprediction in the maps JavaScript API?

See Libraries in the Maps JavaScript API. Restricts predictions to the specified country (ISO 3166-1 Alpha-2 country code, case insensitive). For example, 'us', 'br', or 'au'. You can provide a single one, or an array of up to five country code strings. google.maps.places. AutocompletePrediction interface

What is the Google Places API?

The Google Places API is a service that returns places predictions using HTTP requests. The service can be used to provide an autocomplete functionality for text-based geographic searches by returning places such as businesses, addresses and points of interest as a user types.


1 Answers

For AutocompleteService in the google.maps.places JavaScript library:

AutocompleteService#getPlacePredictions() appears to be used for more detailed searches when you only want places returned. Meanwhile, AutocompleteService#getQueryPredictions() returns results that may not represent actual places (as such, its place_id property is optional), so you can do a looser search and suggest queries to the user. Its returned prediction terms may include "categorical terms", such as "restaurant".

getPlacePredictions() takes in AutocompletionRequest while getQueryPredictions() takes in QueryAutocompletionRequest. The former has these properties that the latter does not, all of which are optional: componentRestrictions, offset, origin, sessionToken, types.

getPlacePredictions() passes AutocompletePrediction[] into your callback function while getQueryPredictions() passes in QueryAutocompletePrediction[]. The former object has these properties that the latter does not: distance_meters, structured_formatting, types.

like image 193
Cloud Avatar answered Dec 12 '22 18:12

Cloud