-
Notifications
You must be signed in to change notification settings - Fork 582
/
quickstart.js
124 lines (116 loc) · 4.34 KB
/
quickstart.js
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
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **
'use strict';
function main(origin, destination) {
// [START routes_quickstart]
/**
* 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. Origin waypoint.
*/
// const origin = {}
/**
* Required. Destination waypoint.
*/
// const destination = {}
/**
* Optional. A set of waypoints along the route (excluding terminal points),
* for either stopping at or passing by. Up to 25 intermediate waypoints are
* supported.
*/
// const intermediates = 1234
/**
* Optional. Specifies the mode of transportation.
*/
// const travelMode = {}
/**
* Optional. Specifies how to compute the route. The server
* attempts to use the selected routing preference to compute the route. If
* the routing preference results in an error or an extra long latency, then
* an error is returned. In the future, we might implement a fallback
* mechanism to use a different option when the preferred option does not give
* a valid result. You can specify this option only when the `travel_mode` is
* `DRIVE` or `TWO_WHEELER`, otherwise the request fails.
*/
// const routingPreference = {}
/**
* Optional. Specifies your preference for the quality of the polyline.
*/
// const polylineQuality = {}
/**
* Optional. Specifies the preferred encoding for the polyline.
*/
// const polylineEncoding = {}
/**
* Optional. The departure time. If you don't set this value, then this value
* defaults to the time that you made the request. If you set this value to a
* time that has already occurred, then the request fails.
*/
// const departureTime = {}
/**
* Optional. Specifies whether to calculate alternate routes in addition to the route.
*/
// const computeAlternativeRoutes = true
/**
* Optional. A set of conditions to satisfy that affect the way routes are
* calculated.
*/
// const routeModifiers = {}
/**
* Optional. The BCP-47 language code, such as "en-US" or "sr-Latn". For more
* information, see
* http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. See
* Language Support (https://developers.google.com/maps/faq#languagesupport)
* for the list of supported languages. When you don't provide this value, the
* display language is inferred from the location of the route request.
*/
// const languageCode = 'abc123'
/**
* Optional. Specifies the units of measure for the display fields. This
* includes the `instruction` field in `NavigationInstruction`. The units of
* measure used for the route, leg, step distance, and duration are not
* affected by this value. If you don't provide this value, then the display
* units are inferred from the location of the request.
*/
// const units = {}
// Imports the Routing library
const {RoutesClient} = require('@googlemaps/routing').v2;
// Instantiates a client
const routingClient = new RoutesClient();
async function callComputeRoutes() {
// Construct request
const request = {
origin,
destination,
};
// Run request
const response = await routingClient.computeRoutes(request);
console.log(response);
}
callComputeRoutes();
// [END routes_quickstart]
}
process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));