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

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


class
`google.maps.places.AutocompleteService`

library `"places"`

> [!WARNING]
> **[Deprecated:](https://developers.google.com/maps/deprecations.md.txt)** As of March 1st, 2025, google.maps.places.AutocompleteService is not available to new customers. Please use `AutocompleteSuggestion` instead. At this time, google.maps.places.AutocompleteService is not scheduled to be discontinued, but `AutocompleteSuggestion` is recommended over google.maps.places.AutocompleteService. While google.maps.places.AutocompleteService will continue to receive bug fixes for any major regressions, existing bugs in google.maps.places.AutocompleteService will not be addressed. At least 12 months notice will be given before support is discontinued. Please see <https://developers.google.com/maps/legacy> for additional details and <https://developers.google.com/maps/documentation/javascript/places-migration-overview> for the migration guide.

Contains methods related to retrieving Autocomplete predictions.

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

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

| ### Methods ||
|---|---|
| `getPlacePredictions` | `getPlacePredictions(request[, callback])` **Parameters:** - `request: AutocompletionRequest` The autocompletion request. - `callback: function(Array<AutocompletePrediction> optional, PlacesServiceStatus): void optional` A callback accepting an array of AutocompletePrediction objects and a PlacesServiceStatus value as argument. **Return Value:** `Promise<AutocompleteResponse>` Retrieves place autocomplete predictions based on the supplied autocomplete request. |
| `getQueryPredictions` | `getQueryPredictions(request, callback)` **Parameters:** - `request: QueryAutocompletionRequest` The query autocompletion request. - `callback: function(Array<QueryAutocompletePrediction> optional, PlacesServiceStatus): void` A callback accepting an array of QueryAutocompletePrediction objects and a PlacesServiceStatus value as argument. **Return Value:** None Retrieves query autocomplete predictions based on the supplied query autocomplete request. |

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


interface
`google.maps.places.AutocompletionRequest`

An Autocompletion request to be sent to `AutocompleteService.getPlacePredictions`.

| ### Properties ||
|---|---|
| `input` | **Type:** `string` The user entered input string. |
| `[bounds](https://developers.google.com/maps/documentation/javascript/reference/places-autocomplete-service#AutocompletionRequest.bounds)` optional | > [!WARNING] > **[Deprecated:](https://developers.google.com/maps/deprecations.md.txt)** `bounds` is deprecated as of May 2023. Use `AutocompletionRequest.locationBias` and `AutocompletionRequest.locationRestriction` instead. **Type:** `LatLngBounds|LatLngBoundsLiteral optional` Bounds for prediction biasing. Predictions will be biased towards, but not restricted to, the given `bounds`. Both `location` and `radius` will be ignored if `bounds` is set. |
| `componentRestrictions` optional | **Type:** `ComponentRestrictions optional` The component restrictions. Component restrictions are used to restrict predictions to only those within the parent component. For example, the country. |
| `language` optional | **Type:** `string optional` A language identifier for the language in which the results should be returned, if possible. Results in the selected language may be given a higher ranking, but suggestions are not restricted to this language. See the [list of supported languages](https://developers.google.com/maps/faq.md.txt#languagesupport). |
| `[location](https://developers.google.com/maps/documentation/javascript/reference/places-autocomplete-service#AutocompletionRequest.location)` optional | > [!WARNING] > **[Deprecated:](https://developers.google.com/maps/deprecations.md.txt)** `location` is deprecated as of May 2023. Use `AutocompletionRequest.locationBias` and `AutocompletionRequest.locationRestriction` instead. **Type:** `LatLng optional` Location for prediction biasing. Predictions will be biased towards the given `location` and `radius`. Alternatively, `bounds` can be used. |
| `locationBias` optional | **Type:** `LocationBias optional` A soft boundary or hint to use when searching for places. |
| `locationRestriction` optional | **Type:** `LocationRestriction optional` Bounds to constrain search results. |
| `offset` optional | **Type:** `number optional` The character position in the input term at which the service uses text for predictions (the position of the cursor in the input field). |
| `origin` optional | **Type:** `LatLng|LatLngLiteral optional` The location where `AutocompletePrediction.distance_meters` is calculated from. |
| `[radius](https://developers.google.com/maps/documentation/javascript/reference/places-autocomplete-service#AutocompletionRequest.radius)` optional | > [!WARNING] > **[Deprecated:](https://developers.google.com/maps/deprecations.md.txt)** `radius` is deprecated as of May 2023. Use `AutocompletionRequest.locationBias` and `AutocompletionRequest.locationRestriction` instead. **Type:** `number optional` The radius of the area used for prediction biasing. The `radius` is specified in meters, and must always be accompanied by a `location` property. Alternatively, `bounds` can be used. |
| `region` optional | **Type:** `string optional` A region code which is used for result formatting and for result filtering. It does not restrict the suggestions to this country. The region code accepts a [ccTLD ("top-level domain")](https://en.wikipedia.org/wiki/List_of_Internet_top-level_domains#Country_code_top-level_domains) two-character value. Most ccTLD codes are identical to ISO 3166-1 codes, with some notable exceptions. For example, the United Kingdom's ccTLD is "uk" (`.co.uk`) while its ISO 3166-1 code is "gb" (technically for the entity of "The United Kingdom of Great Britain and Northern Ireland"). |
| `sessionToken` optional | **Type:** `AutocompleteSessionToken optional` Unique reference used to bundle individual requests into sessions. |
| `types` optional | **Type:** `Array<string> optional` The types of predictions to be returned. For supported types, see the [developer's guide](https://developers.google.com/maps/documentation/javascript/places-autocomplete#constrain-place-types). If no types are specified, all types will be returned. |

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


interface
`google.maps.places.AutocompleteResponse`

An Autocomplete response returned by the call to `AutocompleteService.getPlacePredictions` containing a list of `AutocompletePrediction`s.

| ### Properties ||
|---|---|
| `predictions` | **Type:** `Array<AutocompletePrediction>` The list of `AutocompletePrediction`s. |

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


interface
`google.maps.places.QueryAutocompletionRequest`

A QueryAutocompletion request to be sent to the `QueryAutocompleteService`.

| ### Properties ||
|---|---|
| `input` | **Type:** `string` The user entered input string. |
| `bounds` optional | **Type:** `LatLngBounds|LatLngBoundsLiteral optional` Bounds for prediction biasing. Predictions will be biased towards, but not restricted to, the given `bounds`. Both `location` and `radius` will be ignored if `bounds` is set. |
| `location` optional | **Type:** `LatLng optional` Location for prediction biasing. Predictions will be biased towards the given `location` and `radius`. Alternatively, `bounds` can be used. |
| `offset` optional | **Type:** `number optional` The character position in the input term at which the service uses text for predictions (the position of the cursor in the input field). |
| `radius` optional | **Type:** `number optional` The radius of the area used for prediction biasing. The `radius` is specified in meters, and must always be accompanied by a `location` property. Alternatively, `bounds` can be used. |

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


interface
`google.maps.places.ComponentRestrictions`

Defines the component restrictions that can be used with the autocomplete service.

| ### Properties ||
|---|---|
| `country` optional | **Type:** `string|Array<string> optional` 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. |

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


interface
`google.maps.places.AutocompletePrediction`

Represents a single autocomplete prediction.

| ### Properties ||
|---|---|
| `description` | **Type:** `string` This is the unformatted version of the query suggested by the Places service. |
| `matched_substrings` | **Type:** `Array<PredictionSubstring>` A set of substrings in the place's description that match elements in the user's input, suitable for use in highlighting those substrings. Each substring is identified by an offset and a length, expressed in unicode characters. |
| `place_id` | **Type:** `string` A place ID that can be used to retrieve details about this place using the place details service (see `PlacesService.getDetails`). |
| `structured_formatting` | **Type:** `StructuredFormatting` Structured information about the place's description, divided into a main text and a secondary text, including an array of matched substrings from the autocomplete input, identified by an offset and a length, expressed in unicode characters. |
| `terms` | **Type:** `Array<PredictionTerm>` Information about individual terms in the above description, from most to least specific. For example, "Taco Bell", "Willitis", and "CA". |
| `types` | **Type:** `Array<string>` An array of types that the prediction belongs to, for example `'establishment'` or `'geocode'`. |
| `distance_meters` optional | **Type:** `number optional` The distance in meters of the place from the `AutocompletionRequest.origin`. |

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


interface
`google.maps.places.QueryAutocompletePrediction`

Represents a single Query Autocomplete prediction.

| ### Properties ||
|---|---|
| `description` | **Type:** `string` This is the unformatted version of the query suggested by the Places service. |
| `matched_substrings` | **Type:** `Array<PredictionSubstring>` A set of substrings in the place's description that match elements in the user's input, suitable for use in highlighting those substrings. Each substring is identified by an offset and a length, expressed in unicode characters. |
| `terms` | **Type:** `Array<PredictionTerm>` Information about individual terms in the above description. Categorical terms come first (for example, "restaurant"). Address terms appear from most to least specific. For example, "San Francisco", and "CA". |
| `place_id` optional | **Type:** `string optional` Only available if prediction is a place. A place ID that can be used to retrieve details about this place using the place details service (see `PlacesService.getDetails`). |

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


interface
`google.maps.places.PredictionTerm`

Represents a prediction term.

| ### Properties ||
|---|---|
| `offset` | **Type:** `number` The offset, in unicode characters, of the start of this term in the description of the place. |
| `value` | **Type:** `string` The value of this term, for example, "Taco Bell". |

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


interface
`google.maps.places.PredictionSubstring`

Represents a prediction substring.

| ### Properties ||
|---|---|
| `length` | **Type:** `number` The length of the substring. |
| `offset` | **Type:** `number` The offset to the substring's start within the description string. |

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


interface
`google.maps.places.StructuredFormatting`

Contains structured information about the place's description, divided into a main text and a secondary text, including an array of matched substrings from the autocomplete input, identified by an offset and a length, expressed in unicode characters.

| ### Properties ||
|---|---|
| `main_text` | **Type:** `string` This is the main text part of the unformatted description of the place suggested by the Places service. Usually the name of the place. |
| `main_text_matched_substrings` | **Type:** `Array<PredictionSubstring>` A set of substrings in the main text that match elements in the user's input, suitable for use in highlighting those substrings. Each substring is identified by an offset and a length, expressed in unicode characters. |
| `secondary_text` | **Type:** `string` This is the secondary text part of the unformatted description of the place suggested by the Places service. Usually the location of the place. |