Class v1.PlacesClient (1.7.0)

Service definition for the Places API. Note: every request (except for Autocomplete requests) requires a field mask set outside of the request proto (all/*, is not assumed). The field mask can be set via the HTTP header X-Goog-FieldMask. See: https://developers.google.com/maps/documentation/places/web-service/choose-fields v1

Package

@googlemaps/places

Constructors

(constructor)(opts, gaxInstance)

constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);

Construct an instance of PlacesClient.

Parameters
Name Description
opts ClientOptions
gaxInstance typeof gax | typeof fallback

: loaded instance of google-gax. Useful if you need to avoid loading the default gRPC version and want to use the fallback HTTP implementation. Load only fallback version and pass it to the constructor: ``` const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC const client = new PlacesClient({fallback: true}, gax); ```

Properties

apiEndpoint

get apiEndpoint(): string;

The DNS address for this API service.

apiEndpoint

static get apiEndpoint(): string;

The DNS address for this API service - same as servicePath.

auth

auth: gax.GoogleAuth;

descriptors

descriptors: Descriptors;

innerApiCalls

innerApiCalls: {
        [name: string]: Function;
    };

pathTemplates

pathTemplates: {
        [name: string]: gax.PathTemplate;
    };

placesStub

placesStub?: Promise<{
        [name: string]: Function;
    }>;

port

static get port(): number;

The port for this API service.

scopes

static get scopes(): never[];

The scopes needed to make gRPC calls for every method defined in this service.

servicePath

static get servicePath(): string;

The DNS address for this API service.

universeDomain

get universeDomain(): string;

warn

warn: (code: string, message: string, warnType?: string) => void;

Methods

autocompletePlaces(request, options)

autocompletePlaces(request?: protos.google.maps.places.v1.IAutocompletePlacesRequest, options?: CallOptions): Promise<[
        protos.google.maps.places.v1.IAutocompletePlacesResponse,
        protos.google.maps.places.v1.IAutocompletePlacesRequest | undefined,
        {} | undefined
    ]>;

Returns predictions for the given input.

Parameters
Name Description
request IAutocompletePlacesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.maps.places.v1.IAutocompletePlacesResponse, protos.google.maps.places.v1.IAutocompletePlacesRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The text string on which to search.
   */
  // const input = 'abc123'
  /**
   *  Optional. Bias results to a specified location.
   *  At most one of `location_bias` or `location_restriction` 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.
   */
  // const locationBias = {}
  /**
   *  Optional. Restrict results to a specified location.
   *  At most one of `location_bias` or `location_restriction` 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.
   */
  // const locationRestriction = {}
  /**
   *  Optional. Included primary Place type (for example, "restaurant" or
   *  "gas_station") in Place Types
   *  (https://developers.google.com/maps/documentation/places/web-service/place-types),
   *  or only `(regions)`, or only `(cities)`. 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.
   */
  // const includedPrimaryTypes = ['abc','def']
  /**
   *  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 `location_restriction` and `included_region_codes` are
   *  set, the results will be located in the area of intersection.
   */
  // const includedRegionCodes = ['abc','def']
  /**
   *  Optional. The language in which to return results. Defaults to en-US. The
   *  results may be in mixed languages if the language used in `input` is
   *  different from `language_code` or if the returned Place does not have a
   *  translation from the local language to `language_code`.
   */
  // const languageCode = 'abc123'
  /**
   *  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. To restrict results to a region, use `region_code_restriction`.
   */
  // const regionCode = 'abc123'
  /**
   *  Optional. The origin point from which to calculate geodesic distance to the
   *  destination (returned as `distance_meters`). If this value is omitted,
   *  geodesic distance will not be returned.
   */
  // const origin = {}
  /**
   *  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 empty, defaults to the length of `input`.
   */
  // const inputOffset = 1234
  /**
   *  Optional. If true, the response will include both Place and query
   *  predictions. Otherwise the response will only return Place predictions.
   */
  // const includeQueryPredictions = true
  /**
   *  Optional. A string which identifies an Autocomplete session for billing
   *  purposes. Must be a URL and filename safe base64 string with at most 36
   *  ASCII characters in length. Otherwise an INVALID_ARGUMENT error is
   *  returned.
   *  The session begins when the user starts typing a query, and concludes when
   *  they select a place and a call to Place Details or Address Validation is
   *  made. Each session can have multiple queries, followed by one Place Details
   *  or Address Validation request. 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 `session_token` 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).
   *  We recommend the following guidelines:
   *  * Use session tokens for all Place Autocomplete calls.
   *  * Generate a fresh token for each session. Using a version 4 UUID is
   *    recommended.
   *  * Ensure that the credentials used for all Place Autocomplete, Place
   *    Details, and Address Validation requests within a session belong to the
   *    same Cloud Console project.
   *  * 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.
   */
  // const sessionToken = 'abc123'

  // Imports the Places library
  const {PlacesClient} = require('@googlemaps/places').v1;

  // Instantiates a client
  const placesClient = new PlacesClient();

  async function callAutocompletePlaces() {
    // Construct request
    const request = {
      input,
    };

    // Run request
    const response = await placesClient.autocompletePlaces(request);
    console.log(response);
  }

  callAutocompletePlaces();

autocompletePlaces(request, options, callback)

autocompletePlaces(request: protos.google.maps.places.v1.IAutocompletePlacesRequest, options: CallOptions, callback: Callback<protos.google.maps.places.v1.IAutocompletePlacesResponse, protos.google.maps.places.v1.IAutocompletePlacesRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IAutocompletePlacesRequest
options CallOptions
callback Callback<protos.google.maps.places.v1.IAutocompletePlacesResponse, protos.google.maps.places.v1.IAutocompletePlacesRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

autocompletePlaces(request, callback)

autocompletePlaces(request: protos.google.maps.places.v1.IAutocompletePlacesRequest, callback: Callback<protos.google.maps.places.v1.IAutocompletePlacesResponse, protos.google.maps.places.v1.IAutocompletePlacesRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IAutocompletePlacesRequest
callback Callback<protos.google.maps.places.v1.IAutocompletePlacesResponse, protos.google.maps.places.v1.IAutocompletePlacesRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

close()

close(): Promise<void>;

Terminate the gRPC channel and close the client.

The client will no longer be usable and all future behavior is undefined.

Returns
Type Description
Promise<void>

{Promise} A promise that resolves when the client is closed.

getPhotoMedia(request, options)

getPhotoMedia(request?: protos.google.maps.places.v1.IGetPhotoMediaRequest, options?: CallOptions): Promise<[
        protos.google.maps.places.v1.IPhotoMedia,
        protos.google.maps.places.v1.IGetPhotoMediaRequest | undefined,
        {} | undefined
    ]>;

Get a photo media with a photo reference string.

Parameters
Name Description
request IGetPhotoMediaRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.maps.places.v1.IPhotoMedia, protos.google.maps.places.v1.IGetPhotoMediaRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing PhotoMedia. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The resource name of a photo media in the format:
   *  `places/{place_id}/photos/{photo_reference}/media`.
   *  The resource name of a photo as returned in a Place object's `photos.name`
   *  field comes with the format
   *  `places/{place_id}/photos/{photo_reference}`. You need to append `/media`
   *  at the end of the photo resource to get the photo media resource name.
   */
  // const name = 'abc123'
  /**
   *  Optional. Specifies the maximum desired width, in pixels, of the image. If
   *  the image is smaller than the values specified, the original image will be
   *  returned. If the image is larger in either dimension, it will be scaled to
   *  match the smaller of the two dimensions, restricted to its original aspect
   *  ratio. Both the max_height_px and max_width_px properties accept an integer
   *  between 1 and 4800, inclusively. If the value is not within the allowed
   *  range, an INVALID_ARGUMENT error will be returned.
   *  At least one of max_height_px or max_width_px needs to be specified. If
   *  neither max_height_px nor max_width_px is specified, an INVALID_ARGUMENT
   *  error will be returned.
   */
  // const maxWidthPx = 1234
  /**
   *  Optional. Specifies the maximum desired height, in pixels, of the image. If
   *  the image is smaller than the values specified, the original image will be
   *  returned. If the image is larger in either dimension, it will be scaled to
   *  match the smaller of the two dimensions, restricted to its original aspect
   *  ratio. Both the max_height_px and max_width_px properties accept an integer
   *  between 1 and 4800, inclusively. If the value is not within the allowed
   *  range, an INVALID_ARGUMENT error will be returned.
   *  At least one of max_height_px or max_width_px needs to be specified. If
   *  neither max_height_px nor max_width_px is specified, an INVALID_ARGUMENT
   *  error will be returned.
   */
  // const maxHeightPx = 1234
  /**
   *  Optional. If set, skip the default HTTP redirect behavior and render a text
   *  format (for example, in JSON format for HTTP use case) response. If not
   *  set, an HTTP redirect will be issued to redirect the call to the image
   *  media. This option is ignored for non-HTTP requests.
   */
  // const skipHttpRedirect = true

  // Imports the Places library
  const {PlacesClient} = require('@googlemaps/places').v1;

  // Instantiates a client
  const placesClient = new PlacesClient();

  async function callGetPhotoMedia() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await placesClient.getPhotoMedia(request);
    console.log(response);
  }

  callGetPhotoMedia();

getPhotoMedia(request, options, callback)

getPhotoMedia(request: protos.google.maps.places.v1.IGetPhotoMediaRequest, options: CallOptions, callback: Callback<protos.google.maps.places.v1.IPhotoMedia, protos.google.maps.places.v1.IGetPhotoMediaRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IGetPhotoMediaRequest
options CallOptions
callback Callback<protos.google.maps.places.v1.IPhotoMedia, protos.google.maps.places.v1.IGetPhotoMediaRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

getPhotoMedia(request, callback)

getPhotoMedia(request: protos.google.maps.places.v1.IGetPhotoMediaRequest, callback: Callback<protos.google.maps.places.v1.IPhotoMedia, protos.google.maps.places.v1.IGetPhotoMediaRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IGetPhotoMediaRequest
callback Callback<protos.google.maps.places.v1.IPhotoMedia, protos.google.maps.places.v1.IGetPhotoMediaRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

getPlace(request, options)

getPlace(request?: protos.google.maps.places.v1.IGetPlaceRequest, options?: CallOptions): Promise<[
        protos.google.maps.places.v1.IPlace,
        protos.google.maps.places.v1.IGetPlaceRequest | undefined,
        {} | undefined
    ]>;

Get the details of a place based on its resource name, which is a string in the places/{place_id} format.

Parameters
Name Description
request IGetPlaceRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.maps.places.v1.IPlace, protos.google.maps.places.v1.IGetPlaceRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The resource name of a place, in the `places/{place_id}` format.
   */
  // const name = 'abc123'
  /**
   *  Optional. Place details will be displayed with the preferred language if
   *  available.
   *  Current list of supported languages:
   *  https://developers.google.com/maps/faq#languagesupport.
   */
  // const languageCode = 'abc123'
  /**
   *  Optional. The Unicode country/region code (CLDR) of the location where the
   *  request is coming from. This parameter is used to display the place
   *  details, like region-specific place name, if available. The parameter can
   *  affect results based on applicable law.
   *  For more information, see
   *  https://www.unicode.org/cldr/charts/latest/supplemental/territory_language_information.html.
   *  Note that 3-digit region codes are not currently supported.
   */
  // const regionCode = 'abc123'
  /**
   *  Optional. A string which identifies an Autocomplete session for billing
   *  purposes. Must be a URL and filename safe base64 string with at most 36
   *  ASCII characters in length. Otherwise an INVALID_ARGUMENT error is
   *  returned.
   *  The session begins when the user starts typing a query, and concludes when
   *  they select a place and a call to Place Details or Address Validation is
   *  made. Each session can have multiple queries, followed by one Place Details
   *  or Address Validation request. 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 `session_token` 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).
   *  We recommend the following guidelines:
   *  * Use session tokens for all Place Autocomplete calls.
   *  * Generate a fresh token for each session. Using a version 4 UUID is
   *    recommended.
   *  * Ensure that the credentials used for all Place Autocomplete, Place
   *    Details, and Address Validation requests within a session belong to the
   *    same Cloud Console project.
   *  * 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.
   */
  // const sessionToken = 'abc123'

  // Imports the Places library
  const {PlacesClient} = require('@googlemaps/places').v1;

  // Instantiates a client
  const placesClient = new PlacesClient();

  async function callGetPlace() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await placesClient.getPlace(request);
    console.log(response);
  }

  callGetPlace();

getPlace(request, options, callback)

getPlace(request: protos.google.maps.places.v1.IGetPlaceRequest, options: CallOptions, callback: Callback<protos.google.maps.places.v1.IPlace, protos.google.maps.places.v1.IGetPlaceRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IGetPlaceRequest
options CallOptions
callback Callback<protos.google.maps.places.v1.IPlace, protos.google.maps.places.v1.IGetPlaceRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

getPlace(request, callback)

getPlace(request: protos.google.maps.places.v1.IGetPlaceRequest, callback: Callback<protos.google.maps.places.v1.IPlace, protos.google.maps.places.v1.IGetPlaceRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IGetPlaceRequest
callback Callback<protos.google.maps.places.v1.IPlace, protos.google.maps.places.v1.IGetPlaceRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

getProjectId()

getProjectId(): Promise<string>;
Returns
Type Description
Promise<string>

getProjectId(callback)

getProjectId(callback: Callback<string, undefined, undefined>): void;
Parameter
Name Description
callback Callback<string, undefined, undefined>
Returns
Type Description
void

initialize()

initialize(): Promise<{
        [name: string]: Function;
    }>;

Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.

You can await on this method if you want to make sure the client is initialized.

Returns
Type Description
Promise<{ [name: string]: Function; }>

{Promise} A promise that resolves to an authenticated service stub.

matchPhotoFromPhotoName(photoName)

matchPhotoFromPhotoName(photoName: string): string | number;

Parse the photo from Photo resource.

Parameter
Name Description
photoName string

A fully-qualified path representing Photo resource.

Returns
Type Description
string | number

{string} A string representing the photo.

matchPhotoReferenceFromPhotoMediaName(photoMediaName)

matchPhotoReferenceFromPhotoMediaName(photoMediaName: string): string | number;

Parse the photo_reference from PhotoMedia resource.

Parameter
Name Description
photoMediaName string

A fully-qualified path representing PhotoMedia resource.

Returns
Type Description
string | number

{string} A string representing the photo_reference.

matchPlaceFromPhotoName(photoName)

matchPlaceFromPhotoName(photoName: string): string | number;

Parse the place from Photo resource.

Parameter
Name Description
photoName string

A fully-qualified path representing Photo resource.

Returns
Type Description
string | number

{string} A string representing the place.

matchPlaceFromReviewName(reviewName)

matchPlaceFromReviewName(reviewName: string): string | number;

Parse the place from Review resource.

Parameter
Name Description
reviewName string

A fully-qualified path representing Review resource.

Returns
Type Description
string | number

{string} A string representing the place.

matchPlaceIdFromPhotoMediaName(photoMediaName)

matchPlaceIdFromPhotoMediaName(photoMediaName: string): string | number;

Parse the place_id from PhotoMedia resource.

Parameter
Name Description
photoMediaName string

A fully-qualified path representing PhotoMedia resource.

Returns
Type Description
string | number

{string} A string representing the place_id.

matchPlaceIdFromPlaceName(placeName)

matchPlaceIdFromPlaceName(placeName: string): string | number;

Parse the place_id from Place resource.

Parameter
Name Description
placeName string

A fully-qualified path representing Place resource.

Returns
Type Description
string | number

{string} A string representing the place_id.

matchReviewFromReviewName(reviewName)

matchReviewFromReviewName(reviewName: string): string | number;

Parse the review from Review resource.

Parameter
Name Description
reviewName string

A fully-qualified path representing Review resource.

Returns
Type Description
string | number

{string} A string representing the review.

photoMediaPath(placeId, photoReference)

photoMediaPath(placeId: string, photoReference: string): string;

Return a fully-qualified photoMedia resource name string.

Parameters
Name Description
placeId string
photoReference string
Returns
Type Description
string

{string} Resource name string.

photoPath(place, photo)

photoPath(place: string, photo: string): string;

Return a fully-qualified photo resource name string.

Parameters
Name Description
place string
photo string
Returns
Type Description
string

{string} Resource name string.

placePath(placeId)

placePath(placeId: string): string;

Return a fully-qualified place resource name string.

Parameter
Name Description
placeId string
Returns
Type Description
string

{string} Resource name string.

reviewPath(place, review)

reviewPath(place: string, review: string): string;

Return a fully-qualified review resource name string.

Parameters
Name Description
place string
review string
Returns
Type Description
string

{string} Resource name string.

searchNearby(request, options)

searchNearby(request?: protos.google.maps.places.v1.ISearchNearbyRequest, options?: CallOptions): Promise<[
        protos.google.maps.places.v1.ISearchNearbyResponse,
        protos.google.maps.places.v1.ISearchNearbyRequest | undefined,
        {} | undefined
    ]>;

Search for places near locations.

Parameters
Name Description
request ISearchNearbyRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.maps.places.v1.ISearchNearbyResponse, protos.google.maps.places.v1.ISearchNearbyRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing SearchNearbyResponse. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Place details will be displayed with the preferred language if available.
   *  If the language code is unspecified or unrecognized, place details of any
   *  language may be returned, with a preference for English if such details
   *  exist.
   *  Current list of supported languages:
   *  https://developers.google.com/maps/faq#languagesupport.
   */
  // const languageCode = 'abc123'
  /**
   *  The Unicode country/region code (CLDR) of the location where the
   *  request is coming from. This parameter is used to display the place
   *  details, like region-specific place name, if available. The parameter can
   *  affect results based on applicable law.
   *  For more information, see
   *  https://www.unicode.org/cldr/charts/latest/supplemental/territory_language_information.html.
   *  Note that 3-digit region codes are not currently supported.
   */
  // const regionCode = 'abc123'
  /**
   *  Included Place type (eg, "restaurant" or "gas_station") from
   *  https://developers.google.com/maps/documentation/places/web-service/place-types.
   *  Up to 50 types from Table
   *  A (https://developers.google.com/maps/documentation/places/web-service/place-types#table-a)
   *  may be specified.
   *  If there are any conflicting types, i.e. a type appears in both
   *  included_types and excluded_types, an INVALID_ARGUMENT error is
   *  returned.
   *  If a Place type is specified with multiple type restrictions, only places
   *  that satisfy all of the restrictions are returned. For example, if we
   *  have {included_types = "restaurant", excluded_primary_types =
   *  "restaurant" }, the returned places provide "restaurant"
   *  related services but do not operate primarily as "restaurants".
   */
  // const includedTypes = ['abc','def']
  /**
   *  Excluded Place type (eg, "restaurant" or "gas_station") from
   *  https://developers.google.com/maps/documentation/places/web-service/place-types.
   *  Up to 50 types from Table
   *  A (https://developers.google.com/maps/documentation/places/web-service/place-types#table-a)
   *  may be specified.
   *  If the client provides both included_types (e.g. restaurant) and
   *  excluded_types (e.g. cafe), then the response should include places that
   *  are restaurant but not cafe. The response includes places that match at
   *  least one of the included_types and none of the excluded_types.
   *  If there are any conflicting types, i.e. a type appears in both
   *  included_types and excluded_types, an INVALID_ARGUMENT error is returned.
   *  If a Place type is specified with multiple type restrictions, only places
   *  that satisfy all of the restrictions are returned. For example, if we
   *  have {included_types = "restaurant", excluded_primary_types =
   *  "restaurant" }, the returned places provide "restaurant"
   *  related services but do not operate primarily as "restaurants".
   */
  // const excludedTypes = ['abc','def']
  /**
   *  Included primary Place type (e.g. "restaurant" or "gas_station") from
   *  https://developers.google.com/maps/documentation/places/web-service/place-types.
   *  A place can only have a single primary type from the supported types table
   *  associated with it.
   *  Up to 50 types from Table
   *  A (https://developers.google.com/maps/documentation/places/web-service/place-types#table-a)
   *  may be specified.
   *  If there are any conflicting primary types, i.e. a type appears in both
   *  included_primary_types and excluded_primary_types, an INVALID_ARGUMENT
   *  error is returned.
   *  If a Place type is specified with multiple type restrictions, only places
   *  that satisfy all of the restrictions are returned. For example, if we
   *  have {included_types = "restaurant", excluded_primary_types =
   *  "restaurant" }, the returned places provide "restaurant"
   *  related services but do not operate primarily as "restaurants".
   */
  // const includedPrimaryTypes = ['abc','def']
  /**
   *  Excluded primary Place type (e.g. "restaurant" or "gas_station") from
   *  https://developers.google.com/maps/documentation/places/web-service/place-types.
   *  Up to 50 types from Table
   *  A (https://developers.google.com/maps/documentation/places/web-service/place-types#table-a)
   *  may be specified.
   *  If there are any conflicting primary types, i.e. a type appears in both
   *  included_primary_types and excluded_primary_types, an INVALID_ARGUMENT
   *  error is returned.
   *  If a Place type is specified with multiple type restrictions, only places
   *  that satisfy all of the restrictions are returned. For example, if we
   *  have {included_types = "restaurant", excluded_primary_types =
   *  "restaurant" }, the returned places provide "restaurant"
   *  related services but do not operate primarily as "restaurants".
   */
  // const excludedPrimaryTypes = ['abc','def']
  /**
   *  Maximum number of results to return. It must be between 1 and 20 (default),
   *  inclusively. If the number is unset, it falls back to the upper limit. If
   *  the number is set to negative or exceeds the upper limit, an
   *  INVALID_ARGUMENT error is returned.
   */
  // const maxResultCount = 1234
  /**
   *  Required. The region to search.
   */
  // const locationRestriction = {}
  /**
   *  How results will be ranked in the response.
   */
  // const rankPreference = {}
  /**
   *  Optional. Parameters that affect the routing to the search results.
   */
  // const routingParameters = {}

  // Imports the Places library
  const {PlacesClient} = require('@googlemaps/places').v1;

  // Instantiates a client
  const placesClient = new PlacesClient();

  async function callSearchNearby() {
    // Construct request
    const request = {
      locationRestriction,
    };

    // Run request
    const response = await placesClient.searchNearby(request);
    console.log(response);
  }

  callSearchNearby();

searchNearby(request, options, callback)

searchNearby(request: protos.google.maps.places.v1.ISearchNearbyRequest, options: CallOptions, callback: Callback<protos.google.maps.places.v1.ISearchNearbyResponse, protos.google.maps.places.v1.ISearchNearbyRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request ISearchNearbyRequest
options CallOptions
callback Callback<protos.google.maps.places.v1.ISearchNearbyResponse, protos.google.maps.places.v1.ISearchNearbyRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

searchNearby(request, callback)

searchNearby(request: protos.google.maps.places.v1.ISearchNearbyRequest, callback: Callback<protos.google.maps.places.v1.ISearchNearbyResponse, protos.google.maps.places.v1.ISearchNearbyRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request ISearchNearbyRequest
callback Callback<protos.google.maps.places.v1.ISearchNearbyResponse, protos.google.maps.places.v1.ISearchNearbyRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

searchText(request, options)

searchText(request?: protos.google.maps.places.v1.ISearchTextRequest, options?: CallOptions): Promise<[
        protos.google.maps.places.v1.ISearchTextResponse,
        protos.google.maps.places.v1.ISearchTextRequest | undefined,
        {} | undefined
    ]>;

Text query based place search.

Parameters
Name Description
request ISearchTextRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.maps.places.v1.ISearchTextResponse, protos.google.maps.places.v1.ISearchTextRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing SearchTextResponse. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Required. The text query for textual search.
   */
  // const textQuery = 'abc123'
  /**
   *  Place details will be displayed with the preferred language if available.
   *  If the language code is unspecified or unrecognized, place details of any
   *  language may be returned, with a preference for English if such details
   *  exist.
   *  Current list of supported languages:
   *  https://developers.google.com/maps/faq#languagesupport.
   */
  // const languageCode = 'abc123'
  /**
   *  The Unicode country/region code (CLDR) of the location where the
   *  request is coming from. This parameter is used to display the place
   *  details, like region-specific place name, if available. The parameter can
   *  affect results based on applicable law.
   *  For more information, see
   *  https://www.unicode.org/cldr/charts/latest/supplemental/territory_language_information.html.
   *  Note that 3-digit region codes are not currently supported.
   */
  // const regionCode = 'abc123'
  /**
   *  How results will be ranked in the response.
   */
  // const rankPreference = {}
  /**
   *  The requested place type. Full list of types supported:
   *  https://developers.google.com/maps/documentation/places/web-service/place-types.
   *  Only support one included type.
   */
  // const includedType = 'abc123'
  /**
   *  Used to restrict the search to places that are currently open.  The default
   *  is false.
   */
  // const openNow = true
  /**
   *  Filter out results whose average user rating is strictly less than this
   *  limit. A valid value must be a float between 0 and 5 (inclusively) at a
   *  0.5 cadence i.e. 0, 0.5, 1.0, ... , 5.0  inclusively. The input rating
   *  will round up to the nearest 0.5(ceiling). For instance, a rating of 0.6
   *  will eliminate all results with a less than 1.0 rating.
   */
  // const minRating = 1234
  /**
   *  Maximum number of results to return. It must be between 1 and 20,
   *  inclusively. The default is 20.  If the number is unset, it falls back to
   *  the upper limit. If the number is set to negative or exceeds the upper
   *  limit, an INVALID_ARGUMENT error is returned.
   */
  // const maxResultCount = 1234
  /**
   *  Used to restrict the search to places that are marked as certain price
   *  levels. Users can choose any combinations of price levels. Default to
   *  select all price levels.
   */
  // const priceLevels = [1,2,3,4]
  /**
   *  Used to set strict type filtering for included_type. If set to true, only
   *  results of the same type will be returned. Default to false.
   */
  // const strictTypeFiltering = true
  /**
   *  The region to search. This location serves as a bias which means results
   *  around given location might be returned. Cannot be set along with
   *  location_restriction.
   */
  // const locationBias = {}
  /**
   *  The region to search. This location serves as a restriction which means
   *  results outside given location will not be returned. Cannot be set along
   *  with location_bias.
   */
  // const locationRestriction = {}
  /**
   *  Optional. Set the searchable EV options of a place search request.
   */
  // const evOptions = {}
  /**
   *  Optional. Additional parameters for routing to results.
   */
  // const routingParameters = {}
  /**
   *  Optional. Additional parameters proto for searching along a route.
   */
  // const searchAlongRouteParameters = {}

  // Imports the Places library
  const {PlacesClient} = require('@googlemaps/places').v1;

  // Instantiates a client
  const placesClient = new PlacesClient();

  async function callSearchText() {
    // Construct request
    const request = {
      textQuery,
    };

    // Run request
    const response = await placesClient.searchText(request);
    console.log(response);
  }

  callSearchText();

searchText(request, options, callback)

searchText(request: protos.google.maps.places.v1.ISearchTextRequest, options: CallOptions, callback: Callback<protos.google.maps.places.v1.ISearchTextResponse, protos.google.maps.places.v1.ISearchTextRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request ISearchTextRequest
options CallOptions
callback Callback<protos.google.maps.places.v1.ISearchTextResponse, protos.google.maps.places.v1.ISearchTextRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

searchText(request, callback)

searchText(request: protos.google.maps.places.v1.ISearchTextRequest, callback: Callback<protos.google.maps.places.v1.ISearchTextResponse, protos.google.maps.places.v1.ISearchTextRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request ISearchTextRequest
callback Callback<protos.google.maps.places.v1.ISearchTextResponse, protos.google.maps.places.v1.ISearchTextRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void