<iframe src="https://developers.devsite.google/frame/maps/documentation/javascript/reference/autocomplete-data_b67705b63176ffc361e35de764f19fbf9418e92407ea7e197a937e4efd4acdf2.frame" class="framebox inherit-locale redirect-iframe" allow="clipboard-write https://developers.devsite.google" allowfullscreen is-upgraded></iframe>

## [AutocompleteSuggestion](https://developers.google.com/maps/documentation/javascript/reference/autocomplete-data.md.txt#AutocompleteSuggestion)
class


class
`google.maps.places.AutocompleteSuggestion`

library `"places"`

An Autocomplete suggestion result.

```javascript
const {AutocompleteSuggestion} = await google.maps.importLibrary("places");
```

| ### Static Methods ||
|---|---|
| `fetchAutocompleteSuggestions` | `fetchAutocompleteSuggestions(autocompleteRequest)` **Parameters:** - `autocompleteRequest: AutocompleteRequest` **Return Value:** `Promise<{suggestions:Array<AutocompleteSuggestion>}>` Fetches a list of AutocompleteSuggestions. If a `AutocompleteRequest.sessionToken` is provided in the request, then that session token will automatically be included when calling `Place.fetchFields` for the first time, on each `Place` returned by `PlacePrediction.toPlace` on the resulting `PlacePrediction`s. |

| ### Properties ||
|---|---|
| `placePrediction` readonly | **Type:** `PlacePrediction optional` Contains the human-readable name for the returned result. For establishment results, this is usually the business name and address. If a `AutocompleteRequest.sessionToken` was provided in the AutocompleteRequest used to fetch this AutocompleteSuggestion, the same token will automatically be included when calling `Place.fetchFields` for the first time on the `Place` returned by a call to `PlacePrediction.toPlace`. |

## [AutocompleteRequest](https://developers.google.com/maps/documentation/javascript/reference/autocomplete-data.md.txt#AutocompleteRequest)
interface


interface
`google.maps.places.AutocompleteRequest`

Request interface for `AutocompleteSuggestion.fetchAutocompleteSuggestions`.

| ### Properties ||
|---|---|
| `input` | **Type:** `string` The text string on which to search. |
| `futureOpeningBusinessesIncluded` optional | **Type:** `boolean optional` Include place predictions for businesses that are not yet open but are expected to open in the future. |
| `includedPrimaryTypes` optional | **Type:** `Array<string> optional` Included primary [Place type](https://developers.google.com/maps/documentation/javascript/place-types.md.txt) (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. |
| `includedRegionCodes` optional | **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 both `locationRestriction` and `includedRegionCodes` are set, the results will be located in the area of intersection. |
| `inputOffset` optional | **Type:** `number optional` A zero-based Unicode character offset of `input` indicating the cursor position in `input`. The cursor position may influence what predictions are returned. If not specified, defaults to the length of `input`. |
| `internalUsageAttributionIds` optional | **Type:** `Iterable<string> optional` Identifiers used to attribute calls to specific packages or OSS libraries. |
| `language` optional | **Type:** `string optional` 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 in `input` is different from `language`, or if the returned Place does not have a translation from the local language to `language`. |
| `locationBias` optional | **Type:** `LocationBias optional` Bias results to a specified location. At most one of `locationBias` or `locationRestriction` 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. |
| `locationRestriction` optional | **Type:** `LocationRestriction optional` Restrict results to a specified location. At most one of `locationBias` or `locationRestriction` 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. |
| `origin` optional | **Type:** `LatLng|LatLngLiteral optional` The origin point from which to calculate geodesic distance to the destination (returned as `PlacePrediction.distanceMeters`). If this value is omitted, geodesic distance will not be returned. |
| `pureServiceAreaBusinessesIncluded` optional | **Type:** `boolean optional` Include pure service area businesses if the field is set to true. A pure service area business is a business that visits or delivers to customers directly but does not serve customers at their business address. For example, businesses like cleaning services or plumbers may not have a physical address or location on Google Maps. |
| `region` optional | **Type:** `string optional` 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. |
| `sessionToken` optional | **Type:** `AutocompleteSessionToken optional` A token which identifies an Autocomplete session for billing purposes. Generate a new session token via `AutocompleteSessionToken`. The session begins when the user starts typing a query, and concludes when they select a place and call `Place.fetchFields`. Each session can have multiple queries, followed by one `fetchFields` 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 the `sessionToken` 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 to `AutocompleteSuggestion.fetchAutocompleteSuggestions`, the same token will automatically be included in the first call to fetchFields on a `Place` returned by calling `PlacePrediction.toPlace` on one of the resulting `AutocompleteSuggestion`s. 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. |

## [AutocompleteSessionToken](https://developers.google.com/maps/documentation/javascript/reference/autocomplete-data.md.txt#AutocompleteSessionToken)
class


class
`google.maps.places.AutocompleteSessionToken`

library `"places"`

Represents a session token used for tracking an autocomplete session.

```javascript
const {AutocompleteSessionToken} = await google.maps.importLibrary("places");
```

| ### Constructor ||
|---|---|
| `AutocompleteSessionToken` | `AutocompleteSessionToken()` **Parameters:** None Creates a new instance of `AutocompleteSessionToken`. |

## [PlacePrediction](https://developers.google.com/maps/documentation/javascript/reference/autocomplete-data.md.txt#PlacePrediction)
class


class
`google.maps.places.PlacePrediction`

library `"places"`

Prediction results for a Place Autocomplete prediction.

```javascript
const {PlacePrediction} = await google.maps.importLibrary("places");
```

| ### Properties ||
|---|---|
| `distanceMeters` readonly | **Type:** `number optional` The length of the geodesic in meters from `origin` if `origin` is specified. |
| `mainText` readonly | **Type:** `FormattableText optional` Represents the name of the Place. |
| `placeId` readonly | **Type:** `string` The unique identifier of the suggested Place. This identifier can be used in other APIs that accept Place IDs. |
| `secondaryText` readonly | **Type:** `FormattableText optional` Represents additional disambiguating features (such as a city or region) to further identify the Place. |
| `text` readonly | **Type:** `FormattableText` 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 use `PlacePrediction.mainText` and `PlacePrediction.secondaryText` instead. |
| `types` readonly | **Type:** `Array<string>` List of types that apply to this Place from Table A or Table B in <https://developers.google.com/maps/documentation/places/web-service/place-types>. |

| ### Methods ||
|---|---|
| `![Beta](data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M20.21,17.64l-6.15-8.22V5.57h2.57V3H6.35v2.57h2.57v3.86l-6.3,8.4c-0.44,0.6-0.5,1.41-0.15,2.08C2.8,20.58,3.49,21,4.24,21h14.5c1.11,0,2.01-0.9,2.01-2.01C20.75,18.48,20.53,18,20.21,17.64z' fill='%2301579b'/%3E%3C/svg%3E "Beta")fetchAddressValidation` | > [!WARNING] > **Notice:** Available only in the [v=beta channel](https://developers.google.com/maps/documentation/javascript/versions.md.txt#choosing-the-beta-channel). `fetchAddressValidation(request)` **Parameters:** - `request: AddressValidationRequest` **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 a `Place` representation of this PlacePrediction. A subsequent call to `Place.fetchFields` is required to get full Place details. If a `AutocompleteRequest.sessionToken` was provided in the `AutocompleteRequest` used to fetch this PlacePrediction, the same token will automatically be included when calling fetchFields. Alternatively, when using `PlaceAutocompleteElement` the first call to `Place.fetchFields` on a `Place` returned by `PlacePrediction.toPlace` will automatically include the session token. |

## [StringRange](https://developers.google.com/maps/documentation/javascript/reference/autocomplete-data.md.txt#StringRange)
class


class
`google.maps.places.StringRange`

library `"places"`

Identifies a substring within a given text.

```javascript
const {StringRange} = await google.maps.importLibrary("places");
```

| ### Properties ||
|---|---|
| `endOffset` readonly | **Type:** `number` Zero-based offset of the last Unicode character of the substring (exclusive). |
| `startOffset` readonly | **Type:** `number` Zero-based offset of the first Unicode character of the substring (inclusive). |

## [FormattableText](https://developers.google.com/maps/documentation/javascript/reference/autocomplete-data.md.txt#FormattableText)
class


class
`google.maps.places.FormattableText`

library `"places"`

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

```javascript
const {FormattableText} = await google.maps.importLibrary("places");
```

| ### Properties ||
|---|---|
| `matches` readonly | **Type:** `Array<StringRange>` A list of string ranges identifying where the input request matched in `FormattableText.text`. The ranges can be used to format specific parts of `text`. The substrings may not be exact matches of `AutocompleteRequest.input` if the matching was determined by criteria other than string matching (for example, spell corrections or transliterations). These values are Unicode character offsets of `FormattableText.text`. The ranges are guaranteed to be ordered in increasing offset values. |
| `text` readonly | **Type:** `string` Text that may be used as is or formatted with `FormattableText.matches`. |

| ### Methods ||
|---|---|
| `toString` | `toString()` **Parameters:** None **Return Value:** `string` Returns `FormattableText.text`. |