目录

Matrix Planning for Walking Routes

1 Sample Code

Request:

  1. POST https://mapapi.cloud.huawei.com/mapApi/v1/routeService/walkingMatrix?key=API KEY HTTP/1.1
  2. Content-Type: application/json
  3. Accept: application/json
  4. {
  5.    "origins": [
  6.            {"lng": 2.359782, "lat": 48.862544},
  7.            {"lng": 2.358537, "lat": 48.861443}
  8.    ],
  9.    "destinations": [
  10.            {"lng": 2.361702, "lat": 48.860420}
  11.    ],
  12.    "language": "en"
  13. }

Response:

  1. {
  2.  "originAddresses": [
  3.    "3e Arrondissement, Paris, Ile-de-France, France",
  4.    "3e Arrondissement, Paris, Ile-de-France, France"
  5.  ],
  6.  "returnCode": "0",
  7.  "destinationAddresses": [
  8.    "3e Arrondissement, Paris, Ile-de-France, France"
  9.  ],
  10.  "rows": [
  11.    {
  12.      "cells": [
  13.        {
  14.          "duration": 268,
  15.          "durationText": "4min",
  16.          "distance": 353,
  17.          "distanceText": "353m",
  18.          "status": 0
  19.        }
  20.      ]
  21.    },
  22.    {
  23.      "cells": [
  24.        {
  25.          "duration": 256,
  26.          "durationText": "4min",
  27.          "distance": 352,
  28.          "distanceText": "352m",
  29.          "status": 0
  30.        }
  31.      ]
  32.    }
  33.  ],
  34.  "returnDesc": "OK"
  35. }

2 Input Parameters

HTTP request:

POST  https://mapapi.cloud.huawei.com/mapApi/v1/routeService/walkingMatrix?key=API KEY

Notice:
The API key needs to be encoded using encodeURI. For example, if the original API key is ABC/DFG+, the conversion result is ABC%2FDFG%2B.

The following table describes the request parameters contained in the JSON body. For details about the parameters, please refer to Parameters.

ParameterMandatory (M)/Optional (O)TypeDescription
originsMCoordinate[]Longitudes and latitudes of the departure places.
destinationsMCoordinate[]Longitudes and latitudes of the destinations. A maximum of 5 destinations are allowed.
languageOString(<=6)Language of the distance and journey time descriptions in the returned result. Currently, only zh_CN and en are supported.

Note: The linear distance between the departure place and destination cannot exceed 100 km.

3 Output Parameters

ParameterMandatory (M)/Optional (O)TypeDescription
returnCodeMStringResult code. For details, please refer to Result Codes.
returnDescOStringResult description.
originAddressesOString[]Departure place details.
destinationAddressesOString[]Destination details.
rowsORow[]Distances and journey time of routes between departure places and destinations. For details, please refer to Parameters.

Matrix Planning for Bicycling Routes

1 Sample Code

Request:

  1. POST https://mapapi.cloud.huawei.com/mapApi/v1/routeService/bicyclingMatrix?key=API KEY HTTP/1.1
  2. Content-Type: application/json
  3. Accept: application/json
  4. {
  5.    "origins": [
  6.            {"lng": 2.359782, "lat": 48.862544}
  7.    ],
  8.    "destinations": [
  9.            {"lng": 2.361702, "lat": 48.860420}
  10.    ],
  11.    "language": "en"
  12. }

Response:

  1. {
  2.  "originAddresses": [
  3.    "3e Arrondissement, Paris, Ile-de-France, France"
  4.  ],
  5.  "returnCode": "0",
  6.  "destinationAddresses": [
  7.    "3e Arrondissement, Paris, Ile-de-France, France"
  8.  ],
  9.  "rows": [
  10.    {
  11.      "cells": [
  12.        {
  13.          "duration": 137,
  14.          "durationText": "2min",
  15.          "distance": 353,
  16.          "distanceText": "353m",
  17.          "status": 0
  18.        }
  19.      ]
  20.    }
  21.  ],
  22.  "returnDesc": "OK"
  23. }

2 Input Parameters

HTTP request:

POST  https://mapapi.cloud.huawei.com/mapApi/v1/routeService/bicyclingMatrix?key=API KEY

Notice:
The API key needs to be encoded using encodeURI. For example, if the original API key is ABC/DFG+, the conversion result is ABC%2FDFG%2B.

The following table describes the request parameters contained in the JSON body. For details about the parameters, please refer to Parameters.

ParameterMandatory (M)/Optional (O)TypeDescription
originsMCoordinate[]Longitudes and latitudes of the departure places. A maximum of 5 departure places are allowed.
destinationsMCoordinate[]Longitudes and latitudes of the destinations. A maximum of 5 destinations are allowed.
languageOString(<=6)Language of the distance and journey time descriptions in the returned result. Currently, only zh_CN and en are supported.

Note: The linear distance between the departure place and destination cannot exceed 100 km.

3 Output Parameters

ParameterMandatory (M)/Optional (O)TypeDescription
returnCodeMStringResult code. For details, please refer to Result Codes.
returnDescOStringResult description.
originAddressesOString[]Departure place details.
destinationAddressesOString[]Destination details.
rowsORow[]Distances and journey time of routes between departure places and destinations. For details, please refer to Parameters.

Matrix Planning for Driving Routes

1 Sample Code

Request:

  1. POST https://mapapi.cloud.huawei.com/mapApi/v1/routeService/drivingMatrix?key=API KEY HTTP/1.1
  2. Content-Type: application/json
  3. Accept: application/json
  4. {
  5.    "origins": [
  6.            {"lng": -1.894679, "lat": 54.974887},
  7.            {"lng": -2.882682, "lat": 54.857616}
  8.    ],
  9.    "destinations": [
  10.            {"lng": -1.744955, "lat": 54.775040}
  11.    ],
  12.    "avoid": [1,2],
  13.    "departAt":1678435530,
  14.    "trafficMode":2,
  15.    "language": "en"
  16. }

Response:

  1. {
  2.  "originAddresses": [
  3.    "Ovington, Northumberland, England, United Kingdom",
  4.    "Saint Cuthbert Without, Carlisle, Cumbria, England, United Kingdom"
  5.  ],
  6.  "returnCode": "0",
  7.  "destinationAddresses": [
  8.    "Hedleyhope, Durham, England, United Kingdom"
  9.  ],
  10.  "rows": [
  11.    {
  12.      "cells": [
  13.        {
  14.          "duration": 2183,
  15.          "durationText": "36min",
  16.          "distance": 36129,
  17.          "distanceText": "36.1km",
  18.          "status": 0
  19.        }
  20.      ]
  21.    },
  22.    {
  23.      "cells": [
  24.        {
  25.          "duration": 4888,
  26.          "durationText": "1h21min",
  27.          "distance": 104703,
  28.          "distanceText": "104.7km",
  29.          "status": 0
  30.        }
  31.      ]
  32.    }
  33.  ],
  34.  "returnDesc": "OK"
  35. }

2 Input Parameters

HTTP request:

POST  https://mapapi.cloud.huawei.com/mapApi/v1/routeService/drivingMatrix?key=API KEY

Notice:
The API key needs to be encoded using encodeURI. For example, if the original API key is ABC/DFG+, the conversion result is ABC%2FDFG%2B.

The following table describes the request parameters contained in the JSON body. For details about the parameters, please refer to Parameters.

ParameterMandatory (M)/Optional (O)TypeDescription
originsMCoordinate[]Longitudes and latitudes of the departure places. A maximum of 5 departure places are allowed.
destinationsMCoordinate[]Longitudes and latitudes of the destinations. A maximum of 5 destinations are allowed.
avoid
int[]Indicates the specified type of roads to be avoided. The options are as follows:
  • 1: Avoid toll roads.

  • 2: Avoid expressways.

If this parameter is not included in the request, the route taking the least time will be returned by default.

departAtOlong

Estimated departure time, in seconds since 00:00 on January 1, 1970 (UTC).

The value must be the current time or a future time.

trafficModeOint

Time estimation mode. The options are as follows:

  • 0 (default): best guess

  • 1: The traffic condition is worse than the historical average.

  • 2: The traffic condition is better than the historical average.

languageOString(<=6)Language of the distance and journey time descriptions in the returned result. Currently, only zh_CN and en are supported.

Note: The linear distance between the departure place and destination cannot exceed 100 km.

3 Output Parameters

ParameterMandatory (M)/Optional (O)TypeDescription
returnCodeMStringResult code. For details, please refer to Result Codes.
returnDescOStringResult description.
originAddressesOString[]Departure place details.
destinationAddressesOString[]Destination details.
rowsORow[]Distances and journey time of routes between departure places and destinations. For details, please refer to Parameters.