When you are determining the best route for a ridesharing trip, the fastest route may not always be the best option. You may want to plan your route.
The Routes Preferred API lets you plan a route by specifying
a route objective using the
ComputeCustomRoutes method can also help with route compliance by letting
you minimize the difference between the route selected by the operator and the
Use both the Routes Preferred API and the Navigation SDK to realize the full benefit of route planning.
Enable the ComputeCustomRoutes method
Before you can use the
ComputeCustomRoutes method in your code, you must
enable it. For more information on enabling Routes Preferred API
methods, see Getting Started.
Use the ComputeCustomRoutes method
ComputeCustomRoutes method requires that you specify a response
field mask in the input. You can provide the response field mask by using
the URL parameter
fields, or by using the HTTP/gRPC header
X-Goog-FieldMask. For more information, see
The field mask value is a comma-separated list of field paths. Each field path is a dot-separated list of field names that represent the message hierarchy. A field name is either the JSON object key, or the protobuf field tag name. The field path starts from the top level response message type, and is optionally followed by one or more dots, and then the next level of field name. In general, field paths are constructed in the following way:
A special case field mask is a wildcard “*”, which selects all root-level fields.
For more information, see:
For examples of using the
ComputeCustomRoutes method, see
Computing a Custom Route (Beta) Examples.
Calculating toll fees
For information on calculating toll fees, see Calculate toll fees.
For examples of calculating toll fees, see Computing a Custom Route Examples.