googlemaps / google-maps-services-js

Node.js client library for Google Maps API Web Services
Apache License 2.0
2.88k stars 634 forks source link

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

Open nbouvrette opened 1 year ago

nbouvrette commented 1 year ago

Based on the place autocomplete web service documentation, there is an optional parameter called 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

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 does support the region parameter so I presume it's just missing from this package?

wangela commented 1 year ago

If you would like to upvote the priority of this issue, please comment below or react with :+1: so we can see what is popular when we triage.

@nbouvrette Thank you for opening this issue. 🙏 Please check out these other resources that might help you get to a resolution in the meantime:

This is an automated message, feel free to ignore.