Introducing Places UI Kit: A ready-to-use, low-cost component library that lets you bring the familiar Google Maps UI for Places to any map of your choice. Try it out, andshare your input to help shape the future of GMP!

Autocomplete Data (new)

AutocompleteSuggestionclass

google.maps.places.AutocompleteSuggestionclass

An Autocomplete suggestion result.

Access by callingconst {AutocompleteSuggestion} = await google.maps.importLibrary("places").
SeeLibraries in the Maps JavaScript API.

Static Methods

fetchAutocompleteSuggestions
fetchAutocompleteSuggestions(autocompleteRequest)
Parameters: 
Return Value: Promise<{suggestions:Array<AutocompleteSuggestion>}>
Fetches a list of AutocompleteSuggestions.

If aAutocompleteRequest.sessionToken is provided in the request, then that session token will automatically be included when callingPlace.fetchFields for the first time, on eachPlace returned byPlacePrediction.toPlace on the resultingPlacePredictions.

Properties

placePrediction
Type: PlacePredictionoptional
Contains the human-readable name for the returned result. For establishment results, this is usually the business name and address.

If aAutocompleteRequest.sessionToken was provided in the AutocompleteRequest used to fetch this AutocompleteSuggestion, the same token will automatically be included when callingPlace.fetchFields for the first time on thePlace returned by a call toPlacePrediction.toPlace.

AutocompleteRequestinterface

google.maps.places.AutocompleteRequestinterface

Request interface forAutocompleteSuggestion.fetchAutocompleteSuggestions.

Properties

input
Type: string
The text string on which to search.
includedPrimaryTypesoptional
Type: Array<string>optional
Included primaryPlace type (for example, "restaurant" or "gas_station").

A Place is only returned if its primary type is included in this list. Up to 5 values can be specified. If no types are specified, all Place types are returned.
includedRegionCodesoptional
Type: Array<string>optional
Only include results in the specified regions, specified as up to 15 CLDR two-character region codes. An empty set will not restrict the results. If bothlocationRestriction andincludedRegionCodes are set, the results will be located in the area of intersection.
inputOffsetoptional
Type: numberoptional
A zero-based Unicode character offset ofinput indicating the cursor position ininput. The cursor position may influence what predictions are returned. If not specified, defaults to the length ofinput.
languageoptional
Type: stringoptional
The language in which to return results. Will default to the browser's language preference. The results may be in mixed languages if the language used ininput is different fromlanguage, or if the returned Place does not have a translation from the local language tolanguage.
locationBiasoptional
Type: LocationBiasoptional
Bias results to a specified location.

At most one oflocationBias orlocationRestriction should be set. If neither are set, the results will be biased by IP address, meaning the IP address will be mapped to an imprecise location and used as a biasing signal.
locationRestrictionoptional
Type: LocationRestrictionoptional
Restrict results to a specified location.

At most one oflocationBias orlocationRestriction should be set. If neither are set, the results will be biased by IP address, meaning the IP address will be mapped to an imprecise location and used as a biasing signal.
originoptional
Type: LatLng|LatLngLiteraloptional
The origin point from which to calculate geodesic distance to the destination (returned asPlacePrediction.distanceMeters). If this value is omitted, geodesic distance will not be returned.
regionoptional
Type: stringoptional
The region code, specified as a CLDR two-character region code. This affects address formatting, result ranking, and may influence what results are returned. This does not restrict results to the specified region.
sessionTokenoptional
A token which identifies an Autocomplete session for billing purposes. Generate a new session token viaAutocompleteSessionToken.

The session begins when the user starts typing a query, and concludes when they select a place and callPlace.fetchFields. Each session can have multiple queries, followed by onefetchFields call. The credentials used for each request within a session must belong to the same Google Cloud Console project. Once a session has concluded, the token is no longer valid; your app must generate a fresh token for each session. If thesessionToken parameter is omitted, or if you reuse a session token, the session is charged as if no session token was provided (each request is billed separately).

When a session token is provided in the request toAutocompleteSuggestion.fetchAutocompleteSuggestions, the same token will automatically be included in the first call to fetchFields on aPlace returned by callingPlacePrediction.toPlace on one of the resultingAutocompleteSuggestions.

We recommend the following guidelines:
  • Use session tokens for all Place Autocomplete calls.
  • Generate a fresh token for each session.
  • Be sure to pass a unique session token for each new session. Using the same token for more than one session will result in each request being billed individually.

AutocompleteSessionTokenclass

google.maps.places.AutocompleteSessionTokenclass

Represents a session token used for tracking an autocomplete session.

Access by callingconst {AutocompleteSessionToken} = await google.maps.importLibrary("places").
SeeLibraries in the Maps JavaScript API.

Constructor

AutocompleteSessionToken
AutocompleteSessionToken()
Parameters:  None
Creates a new instance ofAutocompleteSessionToken.

PlacePredictionclass

google.maps.places.PlacePredictionclass

Prediction results for a Place Autocomplete prediction.

Access by callingconst {PlacePrediction} = await google.maps.importLibrary("places").
SeeLibraries in the Maps JavaScript API.

Properties

distanceMeters
Type: numberoptional
The length of the geodesic in meters fromorigin iforigin is specified.
mainText
Type: FormattableTextoptional
Represents the name of the Place.
placeId
Type: string
The unique identifier of the suggested Place. This identifier can be used in other APIs that accept Place IDs.
secondaryText
Type: FormattableTextoptional
Represents additional disambiguating features (such as a city or region) to further identify the Place.
text
Contains the human-readable name for the returned result. For establishment results, this is usually the business name and address.

text is recommended for developers who wish to show a single UI element. Developers who wish to show two separate, but related, UI elements may want to usePlacePrediction.mainText andPlacePrediction.secondaryText instead.
types
Type: Array<string>
List of types that apply to this Place from Table A or Table B inhttps://developers.google.com/maps/documentation/places/web-service/place-types.

Methods

BetafetchAddressValidation

Notice: Available only in thev=beta channel.

fetchAddressValidation(request)
Parameters: 
Return Value: Promise<AddressValidation>
Sends an Address Validation request associated with this autocomplete session (internally populating the request with the autocomplete session token). No place information from the PlacePrediction is included automatically - this is a convenience method to help with autocomplete session management.
toPlace
toPlace()
Parameters:  None
Return Value: Place
Returns aPlace representation of this PlacePrediction. A subsequent call toPlace.fetchFields is required to get full Place details.

If aAutocompleteRequest.sessionToken was provided in theAutocompleteRequest used to fetch this PlacePrediction, the same token will automatically be included when calling fetchFields.

Alternatively, when usingPlaceAutocompleteElement the first call toPlace.fetchFields on aPlace returned byPlacePrediction.toPlace will automatically include the session token.

StringRangeclass

google.maps.places.StringRangeclass

Identifies a substring within a given text.

Access by callingconst {StringRange} = await google.maps.importLibrary("places").
SeeLibraries in the Maps JavaScript API.

Properties

endOffset
Type: number
Zero-based offset of the last Unicode character of the substring (exclusive).
startOffset
Type: number
Zero-based offset of the first Unicode character of the substring (inclusive).

FormattableTextclass

google.maps.places.FormattableTextclass

Text representing a Place prediction. The text may be used as is or formatted.

Access by callingconst {FormattableText} = await google.maps.importLibrary("places").
SeeLibraries in the Maps JavaScript API.

Properties

matches
A list of string ranges identifying where the input request matched inFormattableText.text. The ranges can be used to format specific parts oftext. The substrings may not be exact matches ofAutocompleteRequest.input if the matching was determined by criteria other than string matching (for example, spell corrections or transliterations). These values are Unicode character offsets ofFormattableText.text. The ranges are guaranteed to be ordered in increasing offset values.
text
Type: string
Text that may be used as is or formatted withFormattableText.matches.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-07-18 UTC.