Directions Examples

Basic Directions Fast Request

To create a simple Directions Fast request we will provide an `origin` from where a trip starts and a `destination` where it ends. We also set `mode=car’ to get a legal route which a car can take.

Basic Directions Fast - POST Request

Let’s see how to build a POST method request for Direction Fast API for the same scenario from the curbside example.

Basic Directions Flexible - POST Request

Let’s see how to build a POST method request for Directions Flexible API for the same scenario from the trips in future example

Routes with multiple stops

In this example, we will configure a request with multiple waypoints or stops that need to be made before the final destination. We will add 3 location coordinates which should be visited before the route ends at the destination location.

Approach destinations on curbside

In this example, we will make a Directions Flexible request to get a route where all stops are to be approached from the driving side only. We use the `approaches` parameter to configure the approach direction for each stop on the route.

Avoid Tolls & Highways

To get a route between two points which does not go through a toll road or a highway we can make use of the avoid parameter of the Directions API. The avoid parameter can take multiple values in input and then suggests the best feasible route while avoiding the specified objects/roads

Directions for custom truck sizes

Routing requirements for a truck with custom dimensions can be tricky as not all roads are suitable for all types of trucks. Taking wrong and inappropriate routes can result in operational and regulatory setbacks for a business.

Get Shortest Route

When the business requirements are such that a shortest route between 2 places is most desirable, users can make use of the `route_type` parameter of Directions Flexible API to generate a route with least traveling distance.

Plan a future trip

To plan a trip in the future we configure the `departure_time` parameter of the Directions Flexible API along with other constraints. Providing a `departure_time` allows the service to consider the general traffic conditions at the given time and provide the best route and ETAs accordingly.

Legal routes for a given truck weight

Directions Flexible API allows configuring the truck weight when making a request so that the routes returned are safe and legal for the given route to travel on. `truck_wight` parameter is used to eliminate routes which pass through roads with an allowed weight threshold lower than the given weight.

Avoid sharp turns for a truck

It gets complicated and risky for large trucks to maneuver around sharp turns. With Directions Flexible API users can specify the custom turn angles which are safe for their trucks to take. In order to use the `turn_angle_range` parameter, users also need to set the `avoid` property to “sharp_turn”.

Get routes for hazmat load

To get routes for safely transporting hazardous material, use the `hazmat_type` parameter of the Directions Flexible API to avoid unsafe routes for your truck. Users need to provide the type of material that is being carried by the truck to get the legal routes as per the contents of the truck load.