AutocompletePrediction

public abstract class AutocompletePrediction extends Object
implements Parcelable

Represents an autocomplete suggestion of a place, based on a particular text query.

An AutocompletePrediction includes the description of the suggested place as well as basic details including place ID and types.

Nested Class Summary

class AutocompletePrediction.Builder Builder for AutocompletePrediction

Inherited Constant Summary

Public Constructor Summary

Public Method Summary

static AutocompletePrediction.Builder
abstract Integer
getDistanceMeters()
Returns the straight-line distance between the place being referred to by getPlaceId() and the origin specified in the request.
SpannableString
getFullText(CharacterStyle matchStyle)
The full text of a place.
abstract String
getPlaceId()
Returns the place ID of the place being referred to by this prediction.
abstract List<Place.Type>
getPlaceTypes()
This method is deprecated. Use getTypes() instead.
SpannableString
getPrimaryText(CharacterStyle matchStyle)
Returns the primary text of a place.
SpannableString
getSecondaryText(CharacterStyle matchStyle)
Returns the secondary text of a place.
abstract List<String>
getTypes()
Returns the list of place types associated with the place referred to by getPlaceId().

Inherited Method Summary

Public Constructors

public AutocompletePrediction ()

Public Methods

public static AutocompletePrediction.Builder builder (String placeId)

Returns a AutocompletePrediction.Builder.

Any values, besides placeId, that are not explicitly set, default to an empty String or List.

Parameters
placeId

public abstract Integer getDistanceMeters ()

Returns the straight-line distance between the place being referred to by getPlaceId() and the origin specified in the request.

Will return null if the request did not include an origin, or if the predicted place is of a certain type, such as route. See more details about the distance_meters result field.

public SpannableString getFullText (CharacterStyle matchStyle)

The full text of a place. This is a combination of the primary text and the secondary text.

Example: "Eiffel Tower, Avenue Anatole France, Paris, France"

If you do not wish to highlight matches, you can pass null.

Parameters
matchStyle

public abstract String getPlaceId ()

Returns the place ID of the place being referred to by this prediction. For more information on place IDs, see the place ID overview.

public abstract List<Place.Type> getPlaceTypes ()

This method is deprecated.
Use getTypes() instead.

Returns the list of place types associated with the place referred to by getPlaceId(). For more information on place types, see the place types overview.

This list should not be modified.

public SpannableString getPrimaryText (CharacterStyle matchStyle)

Returns the primary text of a place. This will usually be the name of the place.

Example: "Eiffel Tower", "123 Pitt Street"

See getFullText(CharacterStyle) for more information on formatting.

Parameters
matchStyle

public SpannableString getSecondaryText (CharacterStyle matchStyle)

Returns the secondary text of a place. This provides extra context on the place, and can be used as a second line when showing autocomplete predictions.

Example: "Avenue Anatole France, Paris, France", "Sydney, New South Wales"

See getFullText(CharacterStyle) for more information on formatting.

Parameters
matchStyle

public abstract List<String> getTypes ()

Returns the list of place types associated with the place referred to by getPlaceId(). For more information on place types, see the place types overview.

This list should not be modified.