目录

Walking Route Planning

1. Sample Code

Request:

  1. POST https://mapapi.cloud.huawei.com/mapApi/v1/routeService/walking?key=API KEY    HTTP/1.1
  2. Content-Type: application/json
  3. Accept: application/json
  4. {
  5.    "origin": {
  6.        "lng": -4.66529,
  7.        "lat": 54.216608
  8.    },
  9.    "destination": {
  10.        "lng": -4.66552,
  11.        "lat": 54.2166
  12.    }
  13. }

Response:

  1. {
  2.    "routes": [
  3.        {
  4.            "paths": [
  5.                {
  6.                    "duration": 12,
  7.                    "durationInTraffic": 0,
  8.                    "distance": 12,
  9.                    "startLocation": {
  10.                        "lng": -4.665290197110473,
  11.                        "lat": 54.21660781838372
  12.                    },
  13.                    "steps": [
  14.                        {
  15.                            "duration": 0,
  16.                            "orientation": 1,
  17.                            "distance": 0,
  18.                            "startLocation": {
  19.                                "lng": -4.665290197110473,
  20.                                "lat": 54.21660781838372
  21.                            },
  22.                            "action": "straight",
  23.                            "endLocation": {
  24.                                "lng": -4.665290833333334,
  25.                                "lat": 54.216608055555554
  26.                            },
  27.                            "polyline": [
  28.                                {
  29.                                    "lng": -4.66529,
  30.                                    "lat": 54.216608
  31.                                },
  32.                                {
  33.                                    "lng": -4.665291,
  34.                                    "lat": 54.216608
  35.                                }
  36.                            ],
  37.                            "roadName": "Poortown Road"
  38.                        },
  39.                        {
  40.                            "duration": 12,
  41.                            "orientation": 1,
  42.                            "distance": 12,
  43.                            "startLocation": {
  44.                                "lng": -4.665290833333334,
  45.                                "lat": 54.216608055555554
  46.                            },
  47.                            "action": "unknown",
  48.                            "endLocation": {
  49.                                "lng": -4.6654460345493955,
  50.                                "lat": 54.21666592137546
  51.                            },
  52.                            "polyline": [
  53.                                {
  54.                                    "lng": -4.665291,
  55.                                    "lat": 54.216608
  56.                                },
  57.                                {
  58.                                    "lng": -4.665405,
  59.                                    "lat": 54.21665
  60.                                },
  61.                                {
  62.                                    "lng": -4.665446,
  63.                                    "lat": 54.216666
  64.                                }
  65.                            ],
  66.                            "roadName": "Poortown Road"
  67.                        }
  68.                    ],
  69.                    "endLocation": {
  70.                        "lng": -4.6654460345493955,
  71.                        "lat": 54.21666592137546
  72.                    }
  73.                }
  74.            ],
  75.            "bounds": {
  76.                "southwest": {
  77.                    "lng": -4.6655219444444445,
  78.                    "lat": 54.21584277777778
  79.                },
  80.                "northeast": {
  81.                    "lng": -4.662165833333333,
  82.                    "lat": 54.21669555555555
  83.                }
  84.            }
  85.        }
  86.    ],
  87.    "returnCode": "0",
  88.    "returnDesc": "OK"
  89. }

2. Input Parameters

HTTP request:

POST https://mapapi.cloud.huawei.com/mapApi/v1/routeService/walking?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.
Parameter             Mandatory (M)/Optional (O)Type             Description             
originMCoordinate             Longitude and latitude of the departure place.
destinationMCoordinate             Longitude and latitude of the destination.
languageOString(<=6)Language of the distance and journey time descriptions in the returned result. Currently, only zh_CN and en are supported.

3. Output Parameters

Parameter             Mandatory (M)/Optional (O)Type             Description             
returnCodeMStringResult code. For details, please refer to "Result Codes".
returnDescOStringResult description.
routesORoute[]Planned routes from the departure place to the destination. For details, please refer to "Parameters".

Bicycling Route Planning

1. Sample Code

Request:

  1. POST https://mapapi.cloud.huawei.com/mapApi/v1/routeService/bicycling?key=API KEY   HTTP/1.1
  2. Content-Type: application/json
  3. Accept: application/json
  4. {
  5.    "origin": {
  6.        "lng": -4.66529,
  7.        "lat": 54.216608
  8.    },
  9.    "destination": {
  10.        "lng": -4.66552,
  11.        "lat": 54.2166
  12.    }
  13. }

Response:

  1. {
  2.    "routes": [
  3.        {
  4.            "paths": [
  5.                {
  6.                    "duration": 3,
  7.                    "durationInTraffic": 0,
  8.                    "distance": 12,
  9.                    "startLocation": {
  10.                        "lng": -4.665290197110473,
  11.                        "lat": 54.21660781838372
  12.                    },
  13.                    "steps": [
  14.                        {
  15.                            "duration": 0,
  16.                            "orientation": 1,
  17.                            "distance": 0,
  18.                            "startLocation": {
  19.                                "lng": -4.665290197110473,
  20.                                "lat": 54.21660781838372
  21.                            },
  22.                            "action": "straight",
  23.                            "endLocation": {
  24.                                "lng": -4.665290833333334,
  25.                                "lat": 54.216608055555554
  26.                            },
  27.                            "polyline": [
  28.                                {
  29.                                    "lng": -4.66529,
  30.                                    "lat": 54.216608
  31.                                },
  32.                                {
  33.                                    "lng": -4.665291,
  34.                                    "lat": 54.216608
  35.                                }
  36.                            ],
  37.                            "roadName": "Poortown Road"
  38.                        },
  39.                        {
  40.                            "duration": 12,
  41.                            "orientation": 1,
  42.                            "distance": 12,
  43.                            "startLocation": {
  44.                                "lng": -4.665290833333334,
  45.                                "lat": 54.216608055555554
  46.                            },
  47.                            "action": "unknown",
  48.                            "endLocation": {
  49.                                "lng": -4.6654460345493955,
  50.                                "lat": 54.21666592137546
  51.                            },
  52.                            "polyline": [
  53.                                {
  54.                                    "lng": -4.665291,
  55.                                    "lat": 54.216608
  56.                                },
  57.                                {
  58.                                    "lng": -4.665405,
  59.                                    "lat": 54.21665
  60.                                },
  61.                                {
  62.                                    "lng": -4.665446,
  63.                                    "lat": 54.216666
  64.                                }
  65.                            ],
  66.                            "roadName": "Poortown Road"
  67.                        }
  68.                    ],
  69.                    "endLocation": {
  70.                        "lng": -4.6654460345493955,
  71.                        "lat": 54.21666592137546
  72.                    }
  73.                }
  74.            ],
  75.            "bounds": {
  76.                "southwest": {
  77.                    "lng": -4.6655219444444445,
  78.                    "lat": 54.21584277777778
  79.                },
  80.                "northeast": {
  81.                    "lng": -4.662165833333333,
  82.                    "lat": 54.21669555555555
  83.                }
  84.            }
  85.        }
  86.    ],
  87.    "returnCode": "0",
  88.    "returnDesc": "OK"
  89. }

2. Input Parameters

HTTP request:

POST https://mapapi.cloud.huawei.com/mapApi/v1/routeService/bicycling?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.
Parameter             Mandatory (M)/Optional (O)Type             Description             
originMCoordinate             Longitude and latitude of the departure place.
destinationMCoordinate             Longitude and latitude of the destination.
languageOString(<=6)Language of the distance and journey time descriptions in the returned result. Currently, only zh_CN and en are supported.

3. Output Parameters

Parameter             Mandatory (M)/Optional (O)Type             Description             
returnCodeMStringResult code. For details, please refer to "Result Codes".
returnDescOStringResult description.
routesORoute[]Planned routes from the departure place to the destination. For details, please refer to "Parameters".

Driving Route Planning

1. Sample Code

Request:

  1. POST https://mapapi.cloud.huawei.com/mapApi/v1/routeService/driving?key=API KEY   HTTP/1.1
  2. Content-Type: application/json
  3. Accept: application/json
  4. {
  5.    "origin": {
  6.        "lng": -4.66529,
  7.        "lat": 54.216608
  8.    },
  9.    "destination": {
  10.        "lng": -4.66552,
  11.        "lat": 54.2166
  12.    }
  13. }

Response:

  1. {
  2.    "routes": [
  3.        {
  4.            "paths": [
  5.                {
  6.                    "duration": 1,
  7.                    "durationInTraffic": 0,
  8.                    "distance": 12,
  9.                    "startLocation": {
  10.                        "lng": -4.665290197110473,
  11.                        "lat": 54.21660781838372
  12.                    },
  13.                    "steps": [
  14.                        {
  15.                            "duration": 0,
  16.                            "orientation": 1,
  17.                            "distance": 0,
  18.                            "startLocation": {
  19.                                "lng": -4.665290197110473,
  20.                                "lat": 54.21660781838372
  21.                            },
  22.                            "action": "straight",
  23.                            "endLocation": {
  24.                                "lng": -4.665290833333334,
  25.                                "lat": 54.216608055555554
  26.                            },
  27.                            "polyline": [
  28.                                {
  29.                                    "lng": -4.66529,
  30.                                    "lat": 54.216608
  31.                                },
  32.                                {
  33.                                    "lng": -4.665291,
  34.                                    "lat": 54.216608
  35.                                }
  36.                            ],
  37.                            "roadName": "Poortown Road"
  38.                        },
  39.                        {
  40.                            "duration": 1,
  41.                            "orientation": 1,
  42.                            "distance": 12,
  43.                            "startLocation": {
  44.                                "lng": -4.665290833333334,
  45.                                "lat": 54.216608055555554
  46.                            },
  47.                            "action": "unknown",
  48.                            "endLocation": {
  49.                                "lng": -4.6654460345493955,
  50.                                "lat": 54.21666592137546
  51.                            },
  52.                            "polyline": [
  53.                                {
  54.                                    "lng": -4.665291,
  55.                                    "lat": 54.216608
  56.                                },
  57.                                {
  58.                                    "lng": -4.665405,
  59.                                    "lat": 54.21665
  60.                                },
  61.                                {
  62.                                    "lng": -4.665446,
  63.                                    "lat": 54.216666
  64.                                }
  65.                            ],
  66.                            "roadName": "Poortown Road"
  67.                        }
  68.                    ],
  69.                    "endLocation": {
  70.                        "lng": -4.6654460345493955,
  71.                        "lat": 54.21666592137546
  72.                    }
  73.                }
  74.            ],
  75.            "bounds": {
  76.                "southwest": {
  77.                    "lng": -4.6655219444444445,
  78.                    "lat": 54.21584277777778
  79.                },
  80.                "northeast": {
  81.                    "lng": -4.662165833333333,
  82.                    "lat": 54.21669555555555
  83.                }
  84.            }
  85.        }
  86.    ],
  87.    "returnCode": "0",
  88.    "returnDesc": "OK"
  89. }

2. Input Parameters

HTTP request:

POST https://mapapi.cloud.huawei.com/mapApi/v1/routeService/driving?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.
Parameter             Mandatory (M)/Optional (O)Type             Description             
originMCoordinate             Longitude and latitude of the departure place.
destinationMCoordinate             Longitude and latitude of the destination.
waypointsOCoordinate[]Waypoints. You can specify up to 5 waypoints.
viaTypeOboolean

Waypoint type. The options are as follows:

  • false (default): stopover

  • true: via (pass-by)

optimizeOboolean

Indicates whether to optimize the waypoint.

  • false (default): no

  • true: yes

alternativesOboolean

Indicates whether to return multiple planned routes.

The options are as follows:

  • true: yes

  • false (default): no

Note: This parameter is unavailable when waypoints are set.

avoidOint[]

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.

3. Output Parameters

Parameter             Mandatory (M)/Optional (O)Type             Description             
returnCodeMStringResult code. For details, please refer to "Result Codes".
returnDescOStringResult description.
routesORoute[]Planned routes from the departure place to the destination. For details, please refer to "Parameters".