• Optimization
  • Navigation
  • Tracking
  • Maps
  • Places

Avoid service roads for trucks

Implement Using: Distance Matrix Flexible API


In this example, let’s request for distance and duration values for a route that a truck can take while avoiding service roads. We will create a Distance Matrix Flexible request with 2 origins (O) and 2 destinations (D). We set option as flexible along with:

  • setting mode to “truck” to get distance and duration values for a route that a truck can take
  • avoid option set to “service_road”

Request

1curl --location 'https://api.nextbillion.io/distancematrix/json?origins=33.782861,-117.23477|33.3220362,-117.2358124&destinations=33.7829837,-117.2300256|33.329168,-117.24246&mode=truck&key=<your_api_key>&option=flexible&avoid=service_road'

Response

1{
2 "status": "Ok",
3 "rows": [
4 {
5 "elements": [
6 {
7 "duration": {
8 "value": 79
9 },
10 "distance": {
11 "value": 552
12 }
13 },
14 {
15 "duration": {
16 "value": 3268
17 },
18 "distance": {

Have Questions ?