From 8bdeb034eada5f0dd3f796fdb4ac16858416d5b2 Mon Sep 17 00:00:00 2001 From: Michael Gauthier Date: Mon, 13 Aug 2018 18:56:36 -0300 Subject: [PATCH] Add new types for autocomplete session support See: - https://developers.google.com/maps/documentation/javascript/places-autocomplete#session_tokens - https://developers.google.com/maps/documentation/javascript/reference/places-autocomplete-service#AutocompleteSessionToken - https://developers.google.com/maps/documentation/javascript/reference/places-service#PlaceDetailsRequest - https://developers.google.com/maps/documentation/javascript/reference/places-autocomplete-service#AutocompletionRequest --- types/googlemaps/googlemaps-tests.ts | 3 ++- types/googlemaps/index.d.ts | 21 ++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/types/googlemaps/googlemaps-tests.ts b/types/googlemaps/googlemaps-tests.ts index 77a2900b7b..e161e8068e 100644 --- a/types/googlemaps/googlemaps-tests.ts +++ b/types/googlemaps/googlemaps-tests.ts @@ -418,7 +418,8 @@ let service = new google.maps.places.PlacesService(new HTMLDivElement()); service.getDetails({ placeId: '-a1', - fields: ['name'] + fields: ['name'], + sessionToken: new google.maps.places.AutocompleteSessionToken() }, (result, status) => { if (status === google.maps.places.PlacesServiceStatus.NOT_FOUND) { return; diff --git a/types/googlemaps/index.d.ts b/types/googlemaps/index.d.ts index 501dd4c1f8..dba5a5a5a1 100644 --- a/types/googlemaps/index.d.ts +++ b/types/googlemaps/index.d.ts @@ -1,14 +1,15 @@ // Type definitions for Google Maps JavaScript API 3.30 // Project: https://developers.google.com/maps/ -// Definitions by: Folia A/S , -// Chris Wrench , -// Kiarash Ghiaseddin , -// Grant Hutchins , -// Denis Atyasov , -// Michael McMullin , -// Martin Costello , +// Definitions by: Folia A/S , +// Chris Wrench , +// Kiarash Ghiaseddin , +// Grant Hutchins , +// Denis Atyasov , +// Michael McMullin , +// Martin Costello , // Sven Kreiss // Umar Bolatov +// Michael Gauthier // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /* @@ -2542,6 +2543,10 @@ declare namespace google.maps { getQueryPredictions(request: QueryAutocompletionRequest, callback: (result: QueryAutocompletePrediction[], status: PlacesServiceStatus) => void): void; } + export class AutocompleteSessionToken { + constructor(); + } + export interface AutocompletionRequest { bounds?: LatLngBounds|LatLngBoundsLiteral; componentRestrictions?: ComponentRestrictions; @@ -2549,6 +2554,7 @@ declare namespace google.maps { location?: LatLng; offset?: number; radius?: number; + sessionToken?: AutocompleteSessionToken; types?: string[]; } @@ -2566,6 +2572,7 @@ declare namespace google.maps { export interface PlaceDetailsRequest { placeId: string; fields?: string[]; + sessionToken?: AutocompleteSessionToken; } export interface PlaceGeometry {