forked from indrimuska/google-maps-api-typings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
3427 lines (3304 loc) · 173 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
declare module '@google/maps' {
/**
* Creates a Google Maps client. The client object contains all the API methods.
*/
export interface CreateClientOptions {
/** API key (required, unless clientID and clientSecret provided). */
key: string;
/** Maps API for Work client ID. */
clientId?: string;
/** Maps API for Work client secret (a.k.a. private key). */
clientSecret?: string;
/** Maps API for Work channel. */
channel?: string;
/** Timeout in milliseconds. (Default: 60 * 1000 ms). */
timeout?: number;
/** Default language for all queries. */
language?: Language;
/** Promise constructor (optional). */
Promise?: PromiseConstructor;
/** Rate options. */
rate?: RateOptions;
/** Retry options. */
retryOptions?: RetryOptions;
}
export interface RateOptions {
/** Controls rate-limiting of requests. Maximum number of requests per period. (Default: 50). */
limit?: number;
/** Period for rate limit, in milliseconds. (Default: 1000 ms). */
period?: number;
}
export interface RetryOptions {
/** If a transient server error occurs, how long to wait before retrying the request, in milliseconds. (Default: 500 ms). */
interval?: number;
}
export function createClient(options: CreateClientOptions): GoogleMapsClient;
/**
* A callback function, which is called asynchronously when an API method completes.
* The callback is given either:
* - a successful `ClientResponse` object; or
* - an error, one of:
* - the string `"timeout"`; or
* - an error from the underlying `http` library; or
* - a `ClientResponse` whose status is not `OK`.
*
* API methods don't require a callback function, if you use the Promise API.
*/
export interface ResponseCallback<T> {
(err: 'timeout' | ClientResponse<T>, response: ClientResponse<T>): void;
}
/**
* The object given to the ResponseCallback, containing the HTTP status and headers, as well as the response JSON.
*/
export interface ClientResponse<T> {
/** The HTTP headers. */
headers: { [index: string]: string };
/** Deserialized JSON object for the API response. */
json: T;
/** The HTTP status. */
status: number;
}
/** A handle that allows cancelling a request, or obtaining a Promise. */
export interface RequestHandle<T> {
/**
* Returns the response as a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).
* This method is only available if you supplied the `Promise` constructor to the `createClient()` method when you constructed
* the client object.
*/
asPromise(): Promise<ClientResponse<T>>;
/**
* Cancels the request.
* The ResponseCallback will not be invoked, and promises will not be settled.
* Use the RequestHandle#finally handler will still be called.
*/
cancel(): void;
/**
* Registers a callback that will be called when the response is finished, either successfully, or with an error,
* or having been cancelled. Use this to clean up resources.
* Returns this handle, for chaining.
*/
finally(callback: Function): RequestHandle<T>;
}
export type LatLngArray = [number, number];
export type LatLngString = string;
export type LatLngLiteral = { lat: number; lng: number };
export type LatLngLiteralVerbose = { latitude: number; longitude: number };
/**
* A latitude, longitude pair. The API methods accept either:
* - a two-item array of [latitude, longitude];
* - a comma-separated string;
* - an object with 'lat', 'lng' properties; or
* - an object with 'latitude', 'longitude' properties.
*/
export type LatLng = (
LatLngArray |
LatLngString |
LatLngLiteral |
LatLngLiteralVerbose
);
/** The bounds parameter defines the latitude/longitude coordinates of the southwest and northeast corners of this bounding box. */
export interface LatLngBounds {
northeast: LatLngLiteral;
southwest: LatLngLiteral;
}
/**
* By default the API will attempt to load the most appropriate language based on the users location or browser settings.
* Some APIs allow you to explicitly set a language when you make a request
*
* @see https://developers.google.com/maps/faq#languagesupport
*/
export type Language = (
/** Arabic */
'ar' |
/** Belarusian */
'be' |
/** Bulgarian */
'bg' |
/** Bengali */
'bn' |
/** Catalan */
'ca' |
/** Czech */
'cs' |
/** Danish */
'da' |
/** German */
'de' |
/** Greek */
'el' |
/** English */
'en' |
/** English (Australian) */
'en-Au' |
/** English (Great Britain) */
'en-GB' |
/** Spanish */
'es' |
/** Basque */
'eu' |
/** Farsi */
'fa' |
/** Finnish */
'fi' |
/** Filipino */
'fil' |
/** French */
'fr' |
/** Galician */
'gl' |
/** Gujarati */
'gu' |
/** Hindi */
'hi' |
/** Croatian */
'hr' |
/** Hungarian */
'hu' |
/** Indonesian */
'id' |
/** Italian */
'it' |
/** Hebrew */
'iw' |
/** Japanese */
'ja' |
/** Kazakh */
'kk' |
/** Kannada */
'kn' |
/** Korean */
'ko' |
/** Kyrgyz */
'ky' |
/** Lithuanian */
'lt' |
/** Latvian */
'lv' |
/** Macedonian */
'mk' |
/** Malayalam */
'ml' |
/** Marathi */
'mr' |
/** Burmese */
'my' |
/** Dutch */
'nl' |
/** Norwegian */
'no' |
/** Punjabi */
'pa' |
/** Polish */
'pl' |
/** Portuguese */
'pt' |
/** Portuguese (Brazil) */
'pt-BR' |
/** Portuguese (Portugal) */
'pt-PT' |
/** Romanian */
'ro' |
/** Russian */
'ru' |
/** Slovak */
'sk' |
/** Slovenian */
'sl' |
/** Albanian */
'sq' |
/** Serbian */
'sr' |
/** Swedish */
'sv' |
/** Tamil */
'ta' |
/** Telugu */
'te' |
/** Thai */
'th' |
/** Tagalog */
'tl' |
/** Turkish */
'tr' |
/** Ukrainian */
'uk' |
/** Uzbek */
'uz' |
/** Vietnamese */
'vi' |
/** Chinese (Simlified) */
'zh-CN' |
/** Chinese (Traditional) */
'zh-TW'
);
type GoogleMapsClientEndpoint<Request, Response> = (query: Request, callback?: ResponseCallback<Response>) => RequestHandle<Response>;
export interface GoogleMapsClient {
/**
* The Directions API is a service that calculates directions between locations using an HTTP request.
*
* With the Directions API, you can:
* - Search for directions for several modes of transportation, including transit, driving, walking or cycling.
* - Return multi-part directions using a series of waypoints.
* - Specify origins, destinations, and waypoints as text strings
* (e.g. "Chicago, IL" or "Darwin, NT, Australia"), or as latitude/longitude coordinates, or as place IDs.
*
* The API returns the most efficient routes when calculating directions. Travel time is the primary factor optimized,
* but the API may also take into account other factors such as distance, number of turns and many more when deciding
* which route is the most efficient.
*
* **Tip:** Calculating directions is a time and resource intensive task. Whenever possible, use the service to calculate
* known addresses ahead of time and store the results in a
* [**temporary cache**](https://developers.google.com/maps/documentation/directions/policies#pre-fetching-caching-or-storage-of-content)
* of your own design.
*
* **Note:** This service is not designed to respond in real time to user input. For dynamic directions calculations
* (for example, within a user interface element), consult the documentation for the
* [Maps JavaScript API Directions Service](https://developers.google.com/maps/documentation/javascript/directions)
*
* @see https://developers.google.com/maps/documentation/directions/intro
*/
directions: GoogleMapsClientEndpoint<DirectionsRequest, DirectionsResponse>;
/**
* The Distance Matrix API is a service that provides travel distance and time for a matrix of origins and destinations.
* The API returns information based on the recommended route between start and end points, as calculated by the Google Maps API,
* and consists of rows containing duration and distance values for each pair.
*
* @see https://developers.google.com/maps/documentation/distance-matrix/intro
*/
distanceMatrix: GoogleMapsClientEndpoint<DistanceMatrixRequest, DistanceMatrixResponse>;
/**
* The Elevation API provides a simple interface to query locations on the earth for elevation data. With the Elevation API,
* you can develop hiking and biking applications, positioning applications, or low resolution surveying applications.
*
* Elevation data is available for all locations on the surface of the earth, including depth locations on the ocean floor
* (which return negative values). In those cases where Google does not possess exact elevation measurements at the precise
* location you request, the service interpolates and returns an averaged value using the four nearest locations.
* Elevation values are expressed relative to local mean sea level (LMSL).
*
* You access the Elevation API through an HTTP interface. Users of the Maps JavaScript API may also access this API directly
* by using the `ElevationService()` object.
* (See [Elevation Service](https://developers.google.com/maps/documentation/javascript/elevation) for more information.)
*
* @see https://developers.google.com/maps/documentation/elevation/intro
*/
elevation: GoogleMapsClientEndpoint<ElevationRequest, ElevationResponse>;
/**
* You may request sampled elevation data along paths, allowing you to calculate elevation changes along routes.
* With the Elevation API, you can develop hiking and biking applications, positioning applications,
* or low resolution surveying applications.
*
* @see https://developers.google.com/maps/documentation/elevation/intro
*/
elevationAlongPath: GoogleMapsClientEndpoint<ElevationAlongPathRequest, ElevationResponse>;
/**
* The Places API allows you to query for place information on a variety of categories, such as: establishments,
* prominent points of interest, geographic locations, and more. You can search for places either by proximity or a text string.
* A Place Search returns a list of places along with summary information about each place; additional information is available
* via a [Place Details](https://developers.google.com/places/web-service/details) query.
*
* A Find Place request takes a text input, and returns a place.
* The text input can be any kind of Places data, for example, a name, address, or phone number.
*
* @see https://developers.google.com/places/web-service/search#FindPlaceRequests
*/
findPlace: GoogleMapsClientEndpoint<FindPlaceRequest, PlaceSearchResponse>;
/**
* **Geocoding** is the process of converting addresses (like "1600 Amphitheatre Parkway, Mountain View, CA")
* into geographic coordinates (like latitude 37.423021 and longitude -122.083739),
* which you can use to place markers on a map, or position the map.
*
* **Note:** This service is generally designed for geocoding static (known in advance) addresses for placement
* of application content on a map; this service is not designed to respond in real time to user input.
* For dynamic geocoding (for example, within a user interface element), consult the documentation for the
* [Maps JavaScript API client geocoder](https://developers.google.com/maps/documentation/javascript/geocoding) and/or the
* [Google Play services Location APIs](https://developer.android.com/google/play-services/location.html).
*
* **Tip:** Geocoding is a time and resource intensive task. Whenever possible, pre-geocode known addresses
* (using the Geocoding API described here or another geocoding service), and store your results in a
* [**temporary cache**](https://developers.google.com/maps/documentation/geocoding/policies#pre-fetching-caching-or-storage-of-content)
* of your own design.
*
* @see https://developers.google.com/maps/documentation/geocoding/intro#GeocodingRequests
*/
geocode: GoogleMapsClientEndpoint<GeocodingRequest, GeocodingResponse>;
/**
* The Geolocation API returns a location and accuracy radius based on information about cell towers and WiFi nodes
* that the mobile client can detect. This document describes the protocol used to send this data to the server and
* to return a response to the client.
*
* @see https://developers.google.com/maps/documentation/geolocation/intro
*/
geolocate: GoogleMapsClientEndpoint<GeolocationRequest, GeolocationResponse>;
/**
* The Roads API takes up to 100 independent coordinates, and returns the closest road segment for each point.
* The points passed do not need to be part of a continuous path.
*
* If you are working with sequential GPS points, use [Snap to Roads](https://developers.google.com/maps/documentation/roads/snap).
*
* @see https://developers.google.com/maps/documentation/roads/nearest
*/
nearestRoads: GoogleMapsClientEndpoint<NearestRoadsRequest, NearestRoadsResponse>;
/**
* Once you have a `place_id` from a Place Search, you can request more details about a particular establishment
* or point of interest by initiating a Place Details request. A Place Details request returns more comprehensive
* information about the indicated place such as its complete address, phone number, user rating and reviews.
*
* @see https://developers.google.com/places/web-service/details
*/
place: GoogleMapsClientEndpoint<PlaceDetailsRequest, PlaceDetailsResponse>;
/**
* The Google Places API Text Search Service is a web service that returns information about a set of places
* based on a string — for example "pizza in New York" or "shoe stores near Ottawa" or "123 Main Street".
* The service responds with a list of places matching the text string and any location bias that has been set.
*
* The service is especially useful for making
* [ambiguous address queries](https://developers.google.com/maps/documentation/geocoding/best-practices) in an automated system,
* and non-address components of the string may match businesses as well as addresses.
* Examples of ambiguous address queries are incomplete addresses, poorly formatted addresses,
* or a request that includes non-address components such as business names.
*
* The search response will include a list of places. You can send a Place Details request
* for more information about any of the places in the response.
*
* @see https://developers.google.com/places/web-service/search#TextSearchRequests
*/
places: GoogleMapsClientEndpoint<PlacesRequest, PlaceSearchResponse>;
/**
* The Place Autocomplete service is a web service that returns place predictions in response to an HTTP request.
* The request specifies a textual search string and optional geographic bounds.
* The service can be used to provide autocomplete functionality for text-based geographic searches,
* by returning places such as businesses, addresses and points of interest as a user types.
*
* @see https://developers.google.com/places/web-service/autocomplete
*/
placesAutoComplete: GoogleMapsClientEndpoint<PlaceAutocompleteRequest, PlaceAutocompleteResponse>;
/**
* A Nearby Search lets you search for places within a specified area.
* You can refine your search request by supplying keywords or specifying the type of place you are searching for.
*
* @see https://developers.google.com/places/web-service/search#PlaceSearchRequests
*/
placesNearby: GoogleMapsClientEndpoint<PlacesNearbyRequest, PlaceSearchResponse>;
/**
* The Place Photo service, part of the Places API, is a read- only API that allows you to add high quality photographic content
* to your application. The Place Photo service gives you access to the millions of photos stored in the Places database.
* When you get place information using a Place Details request, photo references will be returned for relevant photographic content.
* The Nearby Search and Text Search requests also return a single photo reference per place, when relevant.
* Using the Photo service you can then access the referenced photos and resize the image to the optimal size for your application.
*
* @see https://developers.google.com/places/web-service/photos
*/
placesPhoto: GoogleMapsClientEndpoint<PlacePhotoRequest, PlacePhotoResponse>;
/**
* The Query Autocomplete service can be used to provide a query prediction for text-based geographic searches,
* by returning suggested queries as you type.
*
* The Query Autocomplete service allows you to add on-the-fly geographic query predictions to your application.
* Instead of searching for a specific location, a user can type in a categorical search, such as "pizza near New York"
* and the service responds with a list of suggested queries matching the string. As the Query Autocomplete service can match
* on both full words and substrings, applications can send queries as the user types to provide on-the-fly predictions.
*
* @see https://developers.google.com/places/web-service/query
*/
placesQueryAutoComplete: GoogleMapsClientEndpoint<QueryAutocompleteRequest, QueryAutocompleteResponse>;
/**
* The Google Places API Radar Search Service allows you to search for up to 200 places at once,
* but with less detail than is typically returned from a Text Search or Nearby Search request.
* With Radar Search, you can create applications that help users identify specific areas of interest within a geographic area.
*
* The search response will include up to 200 places, and will include only the following information about each place:
* - The `geometry` field containing geographic coordinates.
* - The `place_id`, which you can use in a Place Details request to get more information about the place.
*
* @deprecated Radar search is deprecated as of June 30, 2018. After that time, this feature will no longer be available.
*
* @see https://developers.google.com/places/web-service/search#RadarSearchRequests
*/
placesRadar: GoogleMapsClientEndpoint<PlaceRadarRequest, PlaceSearchResponse>;
/**
* Reverse geocoding is the process of converting geographic coordinates into a human-readable address.
*
* @see https://developers.google.com/maps/documentation/geocoding/intro#ReverseGeocoding
*/
reverseGeocode: GoogleMapsClientEndpoint<ReverseGeocodingRequest, ReverseGeocodingResponse>;
/**
* The Roads API returns the posted speed limit for a given road segment.
* In the case of road segments with variable speed limits, the default speed limit for the segment is returned.
*
* The accuracy of speed limit data returned by the Roads API cannot be guaranteed.
* The speed limit data provided is not real-time, and may be estimated, inaccurate, incomplete, and/or outdated.
* You may report inaccuracies in our speed limit data by filing a case in the
* [Google Cloud Support Portal](https://developers.google.com/maps/premium/support#support_portal).
*
* @see https://developers.google.com/maps/documentation/roads/speed-limits
*/
snappedSpeedLimits: GoogleMapsClientEndpoint<SnappedSpeedLimitsRequest, SpeedLimitsResponse>;
/**
* The Roads API takes up to 100 GPS points collected along a route, and returns a similar set of data,
* with the points snapped to the most likely roads the vehicle was traveling along.
* Optionally, you can request that the points be interpolated, resulting in a path that smoothly follows the geometry of the road.
*
* @see https://developers.google.com/maps/documentation/roads/snap
*/
snapToRoads: GoogleMapsClientEndpoint<SnapToRoadsRequest, SnapToRoadsResponse>;
/**
* The Roads API returns the posted speed limit for a given road segment.
* In the case of road segments with variable speed limits, the default speed limit for the segment is returned.
*
* The accuracy of speed limit data returned by the Roads API cannot be guaranteed.
* The speed limit data provided is not real-time, and may be estimated, inaccurate, incomplete, and/or outdated.
* You may report inaccuracies in our speed limit data by filing a case in the
* [Google Cloud Support Portal](https://developers.google.com/maps/premium/support#support_portal).
*
* @see https://developers.google.com/maps/documentation/roads/speed-limits
*/
speedLimits: GoogleMapsClientEndpoint<SpeedLimitsRequest, SpeedLimitsResponse>;
/**
* The Time Zone API provides a simple interface to request the time zone for locations on the surface of the earth,
* as well as the time offset from UTC for each of those locations. You request the time zone information for
* a specific latitude/longitude pair and date. The API returns the name of that time zone, the time offset from UTC,
* and the daylight savings offset.
*
* @see https://developers.google.com/maps/documentation/timezone/intro
*/
timezone: GoogleMapsClientEndpoint<TimeZoneRequest, TimeZoneResponse>;
}
export interface DirectionsRequest {
/**
* The address, textual latitude/longitude value, or place ID from which you wish to calculate directions.
* - If you pass an address, the Directions service geocodes the string and converts it to a latitude/longitude coordinate
* to calculate directions. This coordinate may be different from that returned by the Geocoding API, for example a building
* entrance rather than its center.
*
* `origin=24+Sussex+Drive+Ottawa+ON`
*
* - If you pass coordinates, they are used unchanged to calculate directions. Ensure that no space exists between the latitude
* and longitude values.
*
* `origin=41.43206,-81.38992`
*
* - Place IDs must be prefixed with `place_id:`. The place ID may only be specified if the request includes an API key or a
* Google Maps APIs Premium Plan client ID. You can retrieve place IDs from the Geocoding API and the Places SDK
* (including Place Autocomplete). For an example using place IDs from Place Autocomplete, see [Place Autocomplete and
* Directions](https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-directions).
*
* `origin=place_id:ChIJ3S-JXmauEmsRUcIaWtf4MzE`
*/
origin: LatLng;
/**
* The address, textual latitude/longitude value, or place ID to which you wish to calculate directions.
* The options for the `destination` parameter are the same as for the `origin` parameter, described above
*/
destination: LatLng;
/**
* Specifies the mode of transport to use when calculating directions
*
* @default TravelMode.driving
*/
mode?: TravelMode;
/**
* Specifies an array of waypoints.
* Waypoints alter a route by routing it through the specified location(s).
* A waypoint is specified as a latitude/longitude coordinate, an encoded polyline, a place ID, or an address which will be geocoded.
* Encoded polylines must be prefixed with `enc:` and followed by a colon (`:`). Place IDs must be prefixed with `place_id:`.
* The place ID may only be specified if the request includes an API key or a Google Maps APIs Premium Plan client ID.
* Waypoints are only supported for driving, walking and bicycling directions.
*/
waypoints?: LatLng[];
/**
* If set to `true`, specifies that the Directions service may provide more than one route alternative in the response.
* Note that providing route alternatives may increase the response time from the server.
*/
alternatives?: boolean;
/** Indicates that the calculated route(s) should avoid the indicated features. */
avoid?: TravelRestriction[];
/**
* The language in which to return results.
*
* - If `language` is not supplied, the API attempts to use the preferred language as specified in the `Accept-Language` header,
* or the native language of the domain from which the request is sent.
* - The API does its best to provide a street address that is readable for both the user and locals. To achieve that goal,
* it returns street addresses in the local language, transliterated to a script readable by the user if necessary,
* observing the preferred language. All other addresses are returned in the preferred language.
* Address components are all returned in the same language, which is chosen from the first component.
* - If a name is not available in the preferred language, the API uses the closest match.
* - The preferred language has a small influence on the set of results that the API chooses to return,
* and the order in which they are returned. The geocoder interprets abbreviations differently depending on language,
* such as the abbreviations for street types, or synonyms that may be valid in one language but not in another.
* For example, utca and tér are synonyms for street in Hungarian.
*/
language?: Language;
/** Specifies the unit system to use when displaying results. */
units?: UnitSystem;
/** Specifies the region code, specified as a ccTLD ("top-level domain") two-character value. */
region?: string;
/**
* Specifies the desired time of arrival for transit directions, in seconds since midnight, January 1, 1970 UTC.
* You can specify either `departure_time` or `arrival_time`, but not both.
* Note that `arrival_time` must be specified as an integer.
*/
arrival_time?: Date | number;
/**
* Specifies the desired time of departure. You can specify the time as an integer in seconds since midnight, January 1, 1970 UTC.
* Alternatively, you can specify a value of `now`, which sets the departure time to the current time (correct to the nearest second).
*
* The departure time may be specified in two cases:
* - For requests where the travel mode is transit: You can optionally specify one of `departure_time` or `arrival_time`.
* If neither time is specified, the `departure_time` defaults to now (that is, the departure time defaults to the current time).
* - For requests where the travel mode is driving: You can specify the `departure_time` to receive a route and trip duration
* (response field: `duration_in_traffic`) that take traffic conditions into account.
* This option is only available if the request contains a valid API key, or a valid Google Maps APIs Premium Plan client ID
* and signature. The `departure_time` must be set to the current time or some time in the future. It cannot be in the past.
*/
departure_time?: Date | number;
/**
* Specifies the assumptions to use when calculating time in traffic.
* This setting affects the value returned in the `duration_in_traffic` field in the response, which contains the predicted time
* in traffic based on historical averages. The `traffic_model` parameter may only be specified for driving directions
* where the request includes a `departure_time`, and only if the request includes an API key or a Google Maps APIs Premium Plan client ID.
*
* The default value of `best_guess` will give the most useful predictions for the vast majority of use cases.
* It is possible the `best_guess` travel time prediction may be *shorter* than `optimistic`, or alternatively,
* *longer* than `pessimistic`, due to the way the `best_guess` prediction model integrates live traffic information.
*
* @default TrafficModel.best_guess
*/
traffic_model?: TrafficModel;
/**
* Specifies one or more preferred modes of transit.
* This parameter may only be specified for transit directions, and only if the request includes an API key or
* a Google Maps APIs Premium Plan client ID.
*/
transit_mode?: TransitMode[];
/**
* Specifies preferences for transit routes.
* Using this parameter, you can bias the options returned, rather than accepting the default best route chosen by the API.
* This parameter may only be specified for transit directions, and only if the request includes an API key or
* a Google Maps APIs Premium Plan client ID.
*/
transit_routing_preference?: TransitRoutingPreference;
/** Wherever to optimize the provided route by rearranging the waypoints in a more efficient order. */
optimize?: boolean;
}
/**
* When you calculate directions, you may specify the transportation mode to use.
* By default, directions are calculated as `driving` directions.
*
* **Note:** Both walking and bicycling directions may sometimes not include clear pedestrian or bicycling paths,
* so these directions will return warnings in the returned result which you must display to the user.
*/
export type TravelMode = (
/** (default) indicates standard driving directions using the road network. */
'driving' |
/** requests walking directions via pedestrian paths & sidewalks (where available). */
'walking' |
/** requests bicycling directions via bicycle paths & preferred streets (where available). */
'bicycling' |
/**
* requests directions via public transit routes (where available).
* If you set the mode to transit, you can optionally specify either a departure_time or an arrival_time.
* If neither time is specified, the departure_time defaults to now (that is, the departure time defaults to the current time).
* You can also optionally include a transit_mode and/or a transit_routing_preference.
*/
'transit'
);
export type TravelRestriction = (
/** indicates that the calculated route should avoid toll roads/bridges. */
'tolls' |
/** indicates that the calculated route should avoid highways. */
'highways' |
/** indicates that the calculated route should avoid ferries. */
'ferries' |
/**
* indicates that the calculated route should avoid indoor steps for walking and transit directions.
* Only requests that include an API key or a Google Maps APIs Premium Plan client ID will receive indoor steps by default.
*/
'indoor'
);
/**
* Directions results contain text within distance fields that may be displayed to the user to indicate the distance of
* a particular "step" of the route. By default, this text uses the unit system of the origin's country or region.
*/
export type UnitSystem = (
/** specifies usage of the metric system. Textual distances are returned using kilometers and meters. */
'metric' |
/** specifies usage of the Imperial (English) system. Textual distances are returned using miles and feet. */
'imperial'
);
export interface DirectionsResponse {
/** contains metadata on the request. */
status: DirectionsReponseStatus;
/**
* contains an array with details about the geocoding of origin, destination and waypoints.
*
* These details will not be present for waypoints specified as textual latitude/longitude values if the service returns no results.
* This is because such waypoints are only reverse geocoded to obtain their representative address after a route has been found.
* An empty JSON object will occupy the corresponding places in the `geocoded_waypoints` array.
*/
geocoded_waypoints: GeocodedWaypoint[];
/**
* contains an array of routes from the origin to the destination.
*
* When the Directions API returns results, it places them within a (JSON) `routes` array. Even if the service returns no results
* (such as if the origin and/or destination doesn't exist) it still returns an empty `routes` array.
* (XML responses consist of zero or more `<route>` elements.)
*
* Each element of the `routes` array contains a single result from the specified origin and destination.
* This route may consist of one or more `legs` depending on whether any waypoints were specified.
* As well, the route also contains copyright and warning information which must be displayed to the user in addition to the
* routing information.
*/
routes: DirectionsRoute[];
/**
* contains an array of available travel modes. This field is returned when a request specifies a travel `mode` and gets no results.
* The array contains the available travel modes in the countries of the given set of waypoints.
* This field is not returned if one or more of the waypoints are `via:` waypoints.
*/
available_travel_modes: string[];
}
export type TrafficModel = (
/**
* indicates that the returned `duration_in_traffic` should be the best estimate of travel time given what is known about
* both historical traffic conditions and live traffic. Live traffic becomes more important the closer the `departure_time` is to now.
*/
'best_guess' |
/**
* indicates that the returned `duration_in_traffic` should be longer than the actual travel time on most days,
* though occasional days with particularly bad traffic conditions may exceed this value.
*/
'pessimistic' |
/**
* indicates that the returned `duration_in_traffic` should be shorter than the actual travel time on most days,
* though occasional days with particularly good traffic conditions may be faster than this value.
*/
'optimistic'
);
export type TransitMode = (
/** indicates that the calculated route should prefer travel by bus. */
'bus' |
/** indicates that the calculated route should prefer travel by subway. */
'subway' |
/** indicates that the calculated route should prefer travel by train. */
'train' |
/** indicates that the calculated route should prefer travel by tram and light rail. */
'tram' |
/**
* indicates that the calculated route should prefer travel by train, tram, light rail, and subway.
* This is equivalent to `transit_mode=train|tram|subway`
*/
'rail'
);
export type TransitRoutingPreference = (
/** indicates that the calculated route should prefer limited amounts of walking. */
'less_walking' |
/** indicates that the calculated route should prefer a limited number of transfers. */
'fewer_transfers'
);
/**
* The `status` field within the Directions response object contains the status of the request, and may contain debugging information
* to help you track down why the Directions service failed.
*/
export type DirectionsReponseStatus = (
/** indicates the response contains a valid `result`. */
'OK' |
/** indicates at least one of the locations specified in the request's origin, destination, or waypoints could not be geocoded. */
'NOT_FOUND' |
/** indicates no route could be found between the origin and destination. */
'ZERO_RESULTS' |
/**
* indicates that too many `waypoints` were provided in the request. For applications using the Directions API as a web service,
* or the [directions service in the Maps JavaScript API](https://developers.google.com/maps/documentation/javascript/directions),
* the maximum allowed number of `waypoints` is 23, plus the origin and destination.
*/
'MAX_WAYPOINTS_EXCEEDED' |
/**
* indicates the requested route is too long and cannot be processed.
* This error occurs when more complex directions are returned.
* Try reducing the number of waypoints, turns, or instructions.
*/
'MAX_ROUTE_LENGTH_EXCEEDED ' |
/** indicates that the provided request was invalid. Common causes of this status include an invalid parameter or parameter value. */
'INVALID_REQUEST' |
/**
* indicates any of the following:
* - The API key is missing or invalid.
* - Billing has not been enabled on your account.
* - A self-imposed usage cap has been exceeded.
* - The provided method of payment is no longer valid (for example, a credit card has expired).
* See the [Maps FAQ](https://developers.google.com/maps/faq#over-limit-key-error) to learn how to fix this.
*/
'OVER_DAILY_LIMIT' |
/** indicates the service has received too many requests from your application within the allowed time period. */
'OVER_QUERY_LIMIT' |
/** indicates that the service denied use of the directions service by your application. */
'REQUEST_DENIED' |
/** indicates a directions request could not be processed due to a server error. The request may succeed if you try again. */
'UNKNOWN_ERROR'
);
/**
* Elements in the `geocoded_waypoints` array correspond, by their zero-based position, to the origin,
* the waypoints in the order they are specified, and the destination.
*/
export interface GeocodedWaypoint {
/** indicates the status code resulting from the geocoding operation. */
geocoder_status: GeocodedWaypointStatus;
/**
* indicates that the geocoder did not return an exact match for the original request, though it was able to match part of the
* requested address. You may wish to examine the original request for misspellings and/or an incomplete address.
*
* Partial matches most often occur for street addresses that do not exist within the locality you pass in the request.
* Partial matches may also be returned when a request matches two or more locations in the same locality.
* For example, "21 Henr St, Bristol, UK" will return a partial match for both Henry Street and Henrietta Street.
* Note that if a request includes a misspelled address component, the geocoding service may suggest an alternative address.
* Suggestions triggered in this way will also be marked as a partial match.
*/
partial_match: boolean;
/** unique identifier that can be used with other Google APIs. */
place_id: string;
/**
* indicates the *address type* of the geocoding result used for calculating directions.
*
* An empty list of types indicates there are no known types for the particular address component, for example, Lieu-dit in France.
*/
types: AddressType[];
}
export type GeocodedWaypointStatus = (
/** indicates that no errors occurred; the address was successfully parsed and at least one geocode was returned. */
'OK' |
/**
* indicates that the geocode was successful but returned no results.
* This may occur if the geocoder was passed a non-existent `address`.
*/
'ZERO_RESULTS'
);
export type AddressType = (
/** indicates a precise street address. */
'street_address' |
/** indicates a named route (such as "US 101"). */
'route' |
/** indicates a major intersection, usually of two major roads. */
'intersection' |
/** indicates a political entity. Usually, this type indicates a polygon of some civil administration. */
'political' |
/** indicates the national political entity, and is typically the highest order type returned by the Geocoder. */
'country' |
/**
* indicates a first-order civil entity below the country level. Within the United States, these administrative levels are states.
* Not all nations exhibit these administrative levels. In most cases, `administrative_area_level_1` short names will closely match
* ISO 3166-2 subdivisions and other widely circulated lists; however this is not guaranteed as our geocoding results are based
* on a variety of signals and location data.
*/
'administrative_area_level_1' |
/**
* indicates a second-order civil entity below the country level. Within the United States, these administrative levels are counties.
* Not all nations exhibit these administrative levels.
*/
'administrative_area_level_2' |
/**
* indicates a third-order civil entity below the country level. This type indicates a minor civil division.
* Not all nations exhibit these administrative levels.
*/
'administrative_area_level_3' |
/**
* indicates a fourth-order civil entity below the country level. This type indicates a minor civil division.
* Not all nations exhibit these administrative levels.
*/
'administrative_area_level_4' |
/**
* indicates a fifth-order civil entity below the country level. This type indicates a minor civil division.
* Not all nations exhibit these administrative levels.
*/
'administrative_area_level_5' |
/** indicates a commonly-used alternative name for the entity. */
'colloquial_area' |
/** indicates an incorporated city or town political entity. */
'locality' |
/**
* indicates a specific type of Japanese locality, to facilitate distinction between multiple locality components within a
* Japanese address.
*/
'ward' |
/**
* indicates a first-order civil entity below a locality. For some locations may receive one of the additional types:
* `sublocality_level_1` to `sublocality_level_5`. Each sublocality level is a civil entity. Larger numbers indicate a smaller
* geographic area.
*/
'sublocality' |
/** indicates a named neighborhood */
'neighborhood' |
/** indicates a named location, usually a building or collection of buildings with a common name */
'premise' |
/**
* indicates a first-order entity below a named location, usually a singular building within a collection of buildings with a
* common name.
*/
'subpremise' |
/** indicates a postal code as used to address postal mail within the country. */
'postal_code' |
/** indicates a prominent natural feature. */
'natural_feature' |
/** indicates an airport. */
'airport' |
/** indicates a named park. */
'park' |
/**
* indicates a named point of interest. Typically, these "POI"s are prominent local entities that don't easily fit in another category,
* such as "Empire State Building" or "Statue of Liberty".
*/
'point_of_interest'
);
/**
* This route may consist of one or more `legs` depending on whether any waypoints were specified. As well, the route also contains
* copyright and warning information which must be displayed to the user in addition to the routing information.
*/
export interface DirectionsRoute {
/** contains a short textual description for the route, suitable for naming and disambiguating the route from alternatives. */
summary: string;
/**
* contains an array which contains information about a leg of the route, between two locations within the given route.
* A separate leg will be present for each waypoint or destination specified.
* (A route with no waypoints will contain exactly one leg within the `legs` array.)
* Each leg consists of a series of `steps`.
*/
legs: RouteLeg[];
/**
* contains an array indicating the order of any waypoints in the calculated route.
* This waypoints may be reordered if the request was passed `optimize:true` within its `waypoints` parameter.
*/
waypoint_order: number[];
/**
* contains a single `points` object that holds an encoded polyline representation of the route.
* This polyline is an approximate (smoothed) path of the resulting directions.
*/
overview_polyline: string;
/** contains the viewport bounding box of the `overview_polyline`. */
bounds: LatLngBounds;
/** contains the copyrights text to be displayed for this route. You must handle and display this information yourself. */
copyrights: string;
/** contains an array of warnings to be displayed when showing these directions. You must handle and display these warnings yourself. */
warnings: string[];
/**
* If present, contains the total fare (that is, the total ticket costs) on this route.
* This property is only returned for transit requests and only for routes where fare information is available for all transit legs.
*
* **Note:** The Directions API only returns fare information for requests that contain either an API key or a client ID
* and digital signature.
*/
fare: TransitFare;
/**
* An array of LatLngs representing the entire course of this route. The path is simplified in order to make
* it suitable in contexts where a small number of vertices is required (such as Static Maps API URLs).
*/
overview_path: LatLngLiteral[];
}
export interface TransitFare {
/** An [ISO 4217 currency code](https://en.wikipedia.org/wiki/ISO_4217) indicating the currency that the amount is expressed in. */
currency: string;
/** The total fare amount, in the currency specified above. */
value: number;
/** The total fare amount, formatted in the requested language. */
text: string;
}
/**
* A single leg of the journey from the origin to the destination in the calculated route.
* For routes that contain no waypoints, the route will consist of a single "leg," but for routes that define one or more waypoints,
* the route will consist of one or more legs, corresponding to the specific legs of the journey.
*/
export interface RouteLeg {
/** contains an array of steps denoting information about each separate step of the leg of the journey. */
steps: DirectionsStep[];
/**
* indicates the total distance covered by this leg, as a field with the following elements.
*
* This field may be absent if the distance is unknown.
*/
distance: Distance;
/**
* indicates the total duration of this leg.
*
* This field may be absent if the duration is unknown.
*/
duration: Duration;
/**
* indicates the total duration of this leg.
* This value is an estimate of the time in traffic based on current and historical traffic conditions.
* See the `traffic_model` request parameter for the options you can use to request that the returned value is optimistic, pessimistic,
* or a best-guess estimate. The duration in traffic is returned only if all of the following are true:
*
* - The request includes a valid API key, or a valid Google Maps APIs Premium Plan client ID and signature.
* - The request does not include stopover waypoints. If the request includes waypoints, they must be prefixed with `via:`
* to avoid stopovers.
* - The request is specifically for driving directions—the `mode` parameter is set to `driving`.
* - The request includes a `departure_time` parameter.
* - Traffic conditions are available for the requested route.
*/
duration_in_traffic: Duration;
/** contains the estimated time of arrival for this leg. This property is only returned for transit directions. */
arrival_time: Time;
/**
* contains the estimated time of departure for this leg, specified as a `Time` object.
* The `departure_time` is only available for transit directions.
*/
departure_time: Time;
/**
* contains the latitude/longitude coordinates of the origin of this leg.
* Because the Directions API calculates directions between locations by using the nearest transportation option (usually a road)
* at the start and end points, `start_location` may be different than the provided origin of this leg if, for example,
* a road is not near the origin.
*/
start_location: LatLngLiteral;
/**
* contains the latitude/longitude coordinates of the given destination of this leg.
* Because the Directions API calculates directions between locations by using the nearest transportation option (usually a road)
* at the start and end points, `end_location` may be different than the provided destination of this leg if, for example,
* a road is not near the destination.
*/
end_location: LatLngLiteral;
/** contains the human-readable address (typically a street address) resulting from reverse geocoding the `start_location` of this leg. */
start_address: string;
/** contains the human-readable address (typically a street address) from reverse geocoding the `end_location` of this leg. */
end_address: string;
}
/**
* A step is the most atomic unit of a direction's route, containing a single step describing a specific, single instruction on the journey.
* E.g. "Turn left at W. 4th St." The step not only describes the instruction but also contains distance and duration information relating to
* how this step relates to the following step. For example, a step denoted as "Merge onto I-80 West" may contain a duration of
* "37 miles" and "40 minutes," indicating that the next step is 37 miles/40 minutes from this step.
*
* When using the Directions API to search for transit directions, the steps array will include additional transit details in the form of
* a `transit_details` array. If the directions include multiple modes of transportation, detailed directions will be provided for walking or