googlemaps / googlemaps/google-maps-services-js

The `region` parameter is not implemented for `placeAutocomplete`

Open
#959 1 comment 2 reactions 1 assignee Claimed by @amuramoto View on GitHub
priority: p2 type: bug
Dominant language
TypeScript
Stars
3.1k
Forks
654
Avg merge
3m
Merged PRs (30d)
4

Description

Based on the place autocomplete web service [documentation](https://developers.google.com/maps/documentation/places/web-service/autocomplete), there is an optional parameter called [`region`](https://developers.google.com/maps/documentation/places/web-service/autocomplete#region)

If I understood correctly this parameter allows to bias in the search result to be more locally relevant to a given region.

It looks like this parameter was not implemented in this package.

#### Steps to reproduce

```ts
import { Client as GoogleMapsClient } from '@googlemaps/google-maps-services-js'

const autocompleteResponse = await googleMapsClient
.placeAutocomplete({
params: {
input,
key: process.env.GOOGLE_API_KEY || '',
language: 'en',
region: 'CA',
},
})
.catch(() => null)

```

#### Typescript error
```
Type '{ input: string; key: string; language: string; region: string; }' is not assignable to type '{ input: string; sessiontoken?: string | undefined; offset?: number | undefined; origin?: LatLng | undefined; location?: LatLng | undefined; radius?: number | undefined; language?: string | undefined; types?: PlaceAutocompleteType | undefined; components?: string[] | undefined; strictbounds?: boolean | undefined; } ...'.
Object literal may only specify known properties, and 'region' does not exist in type '{ input: string; sessiontoken?: string | undefined; offset?: number | undefined; origin?: LatLng | undefined; location?: LatLng | undefined; radius?: number | undefined; language?: string | undefined; types?: PlaceAutocompleteType | undefined; components?: string[] | undefined; strictbounds?: boolean | undefined; } ...'.ts(2322)
autocomplete.d.ts(45, 5): The expected type comes from property 'params' which is declared here on type 'PlaceAutocompleteRequest'
```

`Object literal may only specify known properties, and 'region' in type 'PlaceAutocompleteRequest['params']'`

Is the `region` parameter still a valid parameter to use? It looks like the [JavaScript client](https://github.com/googlemaps/js-api-loader) does support the region parameter so I presume it's just missing from this package?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.