'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



Solution 1:[1]

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.

Solution 2:[2]

It's the same thing.

kx.prototype.getPlacePredictions = function(a, b) { _.G("places_impl", (0, _.p)(function() { this.b.getPlacePredictions(a, b) }, this)) };
kx.prototype.getPredictions = kx.prototype.getPlacePredictions;

'getPrediction' method is directly assigned to 'getPlacePrediction' in the JavaScript code from Google API

Solution 3:[3]

I don't see getPredictions documented, perhaps it is an older syntax that is still supported for compatability. You should only use documented functions.

AutocompleteService in the documentation

getPlacePredictions(request:AutocompletionRequest, callback:function(Array, PlacesServiceStatus))

Return Value: None

Retrieves place autocomplete predictions based on the supplied autocomplete request.

Solution 4:[4]

From the docs:

Call getPlacePredictions() to retrieve matching places, or call getQueryPredictions() to retrieve matching places plus suggested search terms.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Kavin Ruengprateepsang
Solution 3 Community
Solution 4 chenop