Directions for custom truck sizes

Implement Using: Directions Flexible API

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. In this example, we will generate a route that is legal for a truck with custom dimensions to take. We configure:

  • origin & destination to to denote the starting and end locations of the trip
  • mode set to “truck” to get a route which a car can take
  • truck_size parameter specifying truck dimensions using its length, width and height

Request

1
curl --location 'https://api.nextbillion.io/directions/json?key=<your_api_key>&origin=36.84750172,-121.40023308&destination=36.85464131,-121.40096997&mode=truck&option=flexible&truck_size=213.36,300,413.36'

Response

1
{
2
"status": "Ok",
3
"routes": [...]
4
}

Following is a visual representation of the above route on a map. We can observe that a direct route is not suggested here due to the custom truck restrictions.

documentation image

© 2024 NextBillion.ai all rights reserved.