This module provides the route planning function.
Atomic service API: This API can be used in atomic services since API version 4.1.0(11).
Start version: 4.1.0(11)
This module provides the methods described in the following table to implement route planning, batch route computation, and trajectory-based road snapping capabilities.
Name | Description |
|---|---|
getDrivingRoutes(params: DrivingRouteParams) | Plans driving routes. |
getDrivingRoutes(context: common.Context, params: DrivingRouteParams) | Plans driving routes. The context can be passed. |
getWalkingRoutes(params: RouteParams) | Plans walking routes. |
getWalkingRoutes(context: common.Context, params: RouteParams) | Plans walking routes. The context can be passed. |
getCyclingRoutes(params: RouteParams) | Plans cycling routes. |
getCyclingRoutes(context: common.Context, params: RouteParams) | Plans cycling routes. The context can be passed. |
getDrivingMatrix(params: DrivingMatrixParams) | Performs batch route computation for driving. |
getDrivingMatrix(context: common.Context, params: DrivingMatrixParams) | Performs batch route computation for driving. The context can be passed. |
getWalkingMatrix(params: MatrixParams) | Performs batch route computation for walking. |
getWalkingMatrix(context: common.Context, params: MatrixParams) | Performs batch route computation for walking. The context can be passed. |
getCyclingMatrix(params: MatrixParams) | Performs batch route computation for cycling. |
getCyclingMatrix(context: common.Context, params: MatrixParams) | Performs batch route computation for cycling. The context can be passed. |
snapToRoads(params: SnapToRoadsParams) | Performs trajectory-based road snapping. |
snapToRoads(context: common.Context, params: SnapToRoadsParams) | Performs trajectory-based road snapping. The context can be transferred. |
This module provides the classes or APIs described in the following table to implement route planning, batch route computation, and trajectory-based road snapping capabilities.
Name | Type | Description |
|---|---|---|
RouteCoordinate | Defines route planning attributes. | |
RouteParams | Defines parameters for planning walking and cycling routes. | |
RouteResult | Defines the route planning result. | |
DrivingRouteParams | Defines parameters for planning driving routes. | |
Route | Defines planned routes from the departure place to the destination. | |
RouteStep | Defines road planning information. | |
RouteRoad | Defines route section information. | |
CoordinateBound | Defines route bounds. | |
Waypoint | Defines waypoint information. | |
TrafficSegment | Defines traffic information. | |
MatrixParams | Defines parameters for batch walking and cycling route computation. | |
MatrixResult | Defines the result of batch route computation. | |
DrivingMatrixParams | Defines parameters for batch driving route computation. | |
MatrixRow | Defines distances and journey time of routes between departure places and destinations. | |
MatrixCell | Defines information about each element in the distance matrix. | |
SnapToRoadsParams | Defines parameters for trajectory-based road snapping. | |
SnapToRoadsResult | Defines the trajectory-based road snapping result. | |
SnappedPoint | Defines road snapping points. |
getDrivingRoutes(params: DrivingRouteParams): Promise<RouteResult>
Plans the driving routes between two locations. This API returns the result asynchronously through a promise.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 4.1.0(11).
System capability: SystemCapability.Map.Core
Start version: 4.1.0(11)
Parameters:
Name | Type | Mandatory | Description |
|---|---|---|---|
params | Yes | Parameters for planning driving routes. |
Returns:
Type | Description |
|---|---|
Promise<RouteResult> | RouteResult object returned through a promise. |
Error codes:
For details about the error codes, please refer to ArkTS API Error Codes.
Error Code | Error Message |
|---|---|
401 | Invalid input parameter. |
1002600001 | System internal error. |
1002600002 | Failed to connect to the Map Kit server. |
1002600003 | App authentication failed. |
1002600004 | The Map permission is not enabled. |
1002600006 | The API call times exceed the quota. |
1002600007 | The API QPS exceeds the quota. |
1002600008 | The API is in arrears. |
1002600009 | The API has not subscribed to any pay-as-you-go package. |
1002600010 | The server is busy. Please wait and try again. |
1002600011 | Server error. |
1002600999 | Unknown error. |
1002602001 | The start and end points do not have home countries, or a service error occurred. |
1002602002 | Cross-region route planning is not supported. |
1002602003 | The number of start points or end points exceed 100. |
1002602004 | The linear distance between the start point and end point exceeds the upper limit. |
1002602005 | The start point, end point, or waypoint does not support navigation. |
1002602006 | The request point is mapped to the same point on the road. |
let params: navi.DrivingRouteParams = {
origins: [{
"latitude": 31.9821213545843,
"longitude": 120.27745557768591
}],
destination: {
"latitude": 31.983545843,
"longitude": 120.27745557768591
},
waypoints: [
{ "latitude": 31.967236140819114, "longitude": 120.27142088866847 },
{ "latitude": 31.972868002238872, "longitude": 120.2943211817165 },
{ "latitude": 31.98469327973332, "longitude": 120.29101107384068 }
],
language: "zh_CN"
};
const result = await navi.getDrivingRoutes(params);
console.info("Succeeded in getting driving routes."); getDrivingRoutes(context: common.Context, params: DrivingRouteParams): Promise<RouteResult>
Plans the driving routes between two locations. The context can be passed. This API returns the result asynchronously through a promise.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 5.0.0(12).
System capability: SystemCapability.Map.Core
Start version: 5.0.0(12)
Parameters:
Name | Type | Mandatory | Description |
|---|---|---|---|
context | Yes | Context. | |
params | Yes | Parameters for planning driving routes. |
Returns:
Type | Description |
|---|---|
Promise<RouteResult> | RouteResult object returned through a promise. |
Error codes:
For details about the error codes, please refer to ArkTS API Error Codes.
Error Code | Error Message |
|---|---|
401 | Invalid input parameter. |
1002600001 | System internal error. |
1002600002 | Failed to connect to the Map Kit server. |
1002600003 | App authentication failed. |
1002600004 | The Map permission is not enabled. |
1002600006 | The API call times exceed the quota. |
1002600007 | The API QPS exceeds the quota. |
1002600008 | The API is in arrears. |
1002600009 | The API has not subscribed to any pay-as-you-go package. |
1002600010 | The server is busy. Please wait and try again. |
1002600011 | Server error. |
1002600999 | Unknown error. |
1002602001 | The start and end points do not have home countries, or a service error occurred. |
1002602002 | Cross-region route planning is not supported. |
1002602003 | The number of start points or end points exceed 100. |
1002602004 | The linear distance between the start point and end point exceeds the upper limit. |
1002602005 | The start point, end point, or waypoint does not support navigation. |
1002602006 | The request point is mapped to the same point on the road. |
let params: navi.DrivingRouteParams = {
origins: [{
"latitude": 31.982129213545843,
"longitude": 120.27745557768591
}],
destination: {
"latitude": 31.9821213545843,
"longitude": 120.277557768591
},
waypoints: [
{ "latitude": 31.967236140819114, "longitude": 120.27142088866847 },
{ "latitude": 31.972868002238872, "longitude": 120.2943211817165 },
{ "latitude": 31.98469327973332, "longitude": 120.29101107384068 }
],
language: "zh_CN"
};
const result = await navi.getDrivingRoutes(getContext(), params);
console.info("Succeeded in getting driving routes."); getWalkingRoutes(params: RouteParams): Promise<RouteResult>
Plans the walking routes between two locations. This API returns the result asynchronously through a promise.
Walking route planning is limited to two locations within a straight-line distance of 150 kilometers.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 4.1.0(11).
System capability: SystemCapability.Map.Core
Start version: 4.1.0(11)
Parameters:
Name | Type | Mandatory | Description |
|---|---|---|---|
params | Yes | Parameters for planning walking routes. |
Returns:
Type | Description |
|---|---|
Promise<RouteResult> | RouteResult object returned through a promise. |
Error codes:
For details about the error codes, please refer to ArkTS API Error Codes.
Error Code | Error Message |
|---|---|
401 | Invalid input parameter. |
1002600001 | System internal error. |
1002600002 | Failed to connect to the Map Kit server. |
1002600003 | App authentication failed. |
1002600004 | The Map permission is not enabled. |
1002600006 | The API call times exceed the quota. |
1002600007 | The API QPS exceeds the quota. |
1002600008 | The API is in arrears. |
1002600009 | The API has not subscribed to any pay-as-you-go package. |
1002600010 | The server is busy. Please wait and try again. |
1002600011 | Server error. |
1002600999 | Unknown error. |
1002602001 | The start and end points do not have home countries, or a service error occurred. |
1002602002 | Cross-region route planning is not supported. |
1002602003 | The number of start points or end points exceed 100. |
1002602004 | The linear distance between the start point and end point exceeds the upper limit. |
1002602005 | The start point, end point, or waypoint does not support navigation. |
1002602006 | The request point is mapped to the same point on the road. |
let params: navi.RouteParams = {
origins: [
{ "latitude": 39.992281, "longitude": 116.31088 },
{ "latitude": 39.996, "longitude": 116.311 }
],
destination: {
"latitude": 39.94,
"longitude": 116.311
},
language: "zh_CN"
};
const result = await navi.getWalkingRoutes(params);
console.info("Succeeded in getting walking routes."); getWalkingRoutes(context: common.Context, params: RouteParams): Promise<RouteResult>
Plans the walking routes between two locations. The context can be passed. This API returns the result asynchronously through a promise.
Walking route planning is limited to locations within a straight-line distance of 150 kilometers.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 5.0.0(12).
System capability: SystemCapability.Map.Core
Start version: 5.0.0(12)
Parameters:
Name | Type | Mandatory | Description |
|---|---|---|---|
context | Yes | Context. | |
params | Yes | Parameters for planning walking routes. |
Returns:
Type | Description |
|---|---|
Promise<RouteResult> | RouteResult object returned through a promise. |
Error codes:
For details about the error codes, please refer to ArkTS API Error Codes.
Error Code | Error Message |
|---|---|
401 | Invalid input parameter. |
1002600001 | System internal error. |
1002600002 | Failed to connect to the Map Kit server. |
1002600003 | App authentication failed. |
1002600004 | The Map permission is not enabled. |
1002600006 | The API call times exceed the quota. |
1002600007 | The API QPS exceeds the quota. |
1002600008 | The API is in arrears. |
1002600009 | The API has not subscribed to any pay-as-you-go package. |
1002600010 | The server is busy. Please wait and try again. |
1002600011 | Server error. |
1002600999 | Unknown error. |
1002602001 | The start and end points do not have home countries, or a service error occurred. |
1002602002 | Cross-region route planning is not supported. |
1002602003 | The number of start points or end points exceed 100. |
1002602004 | The linear distance between the start point and end point exceeds the upper limit. |
1002602005 | The start point, end point, or waypoint does not support navigation. |
1002602006 | The request point is mapped to the same point on the road. |
let params: navi.DrivingRouteParams = {
origins: [{
"latitude": 31.982129213545843,
"longitude": 120.27745557768591
}],
destination: {
"latitude": 31.9821213545843,
"longitude": 120.277557768591
},
waypoints: [
{ "latitude": 31.967236140819114, "longitude": 120.27142088866847 },
{ "latitude": 31.972868002238872, "longitude": 120.2943211817165 },
{ "latitude": 31.98469327973332, "longitude": 120.29101107384068 }
],
language: "zh_CN"
};
const result = await navi.getWalkingRoutes(getContext(), params);
console.info("Succeeded in getting walking routes."); getCyclingRoutes(params: RouteParams): Promise<RouteResult>
Plans the cycling routes between two locations. This API returns the result asynchronously through a promise.
Cycling route planning is limited to locations within a straight-line distance of 500 kilometers.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 4.1.0(11).
System capability: SystemCapability.Map.Core
Start version: 4.1.0(11)
Parameters:
Name | Type | Mandatory | Description |
|---|---|---|---|
params | Yes | Parameters for planning cycling routes. |
Returns:
Type | Description |
|---|---|
Promise<RouteResult> | RouteResult object returned through a promise. |
Error codes:
For details about the error codes, please refer to ArkTS API Error Codes.
Error Code | Error Message |
|---|---|
401 | Invalid input parameter. |
1002600001 | System internal error. |
1002600002 | Failed to connect to the Map Kit server. |
1002600003 | App authentication failed. |
1002600004 | The Map permission is not enabled. |
1002600006 | The API call times exceed the quota. |
1002600007 | The API QPS exceeds the quota. |
1002600008 | The API is in arrears. |
1002600009 | The API has not subscribed to any pay-as-you-go package. |
1002600010 | The server is busy. Please wait and try again. |
1002600011 | Server error. |
1002600999 | Unknown error. |
1002602001 | The start and end points do not have home countries, or a service error occurred. |
1002602002 | Cross-region route planning is not supported. |
1002602003 | The number of start points or end points exceed 100. |
1002602004 | The linear distance between the start point and end point exceeds the upper limit. |
1002602005 | The start point, end point, or waypoint does not support navigation. |
1002602006 | The request point is mapped to the same point on the road. |
let params: navi.RouteParams = {
origins: [{
latitude: 31.984410259206815,
longitude: 118.76625379397866
}],
destination: {
latitude: 30.9844259206815,
longitude: 119.766259397866
},
language: "zh_CN"
};
const result = await navi.getCyclingRoutes(params);
console.info("Succeeded in getting cycling routes."); getCyclingRoutes(context: common.Context, params: RouteParams): Promise<RouteResult>
Plans the cycling routes between two locations. The context can be passed. This API returns the result asynchronously through a promise.
Cycling route planning is limited to locations within a straight-line distance of 500 kilometers.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 5.0.0(12).
System capability: SystemCapability.Map.Core
Start version: 5.0.0(12)
Parameters:
Name | Type | Mandatory | Description |
|---|---|---|---|
context | Yes | Context. | |
params | Yes | Parameters for planning cycling routes. |
Returns:
Type | Description |
|---|---|
Promise<RouteResult> | RouteResult object returned through a promise. |
Error codes:
For details about the error codes, please refer to ArkTS API Error Codes.
Error Code | Error Message |
|---|---|
401 | Invalid input parameter. |
1002600001 | System internal error. |
1002600002 | Failed to connect to the Map Kit server. |
1002600003 | App authentication failed. |
1002600004 | The Map permission is not enabled. |
1002600006 | The API call times exceed the quota. |
1002600007 | The API QPS exceeds the quota. |
1002600008 | The API is in arrears. |
1002600009 | The API has not subscribed to any pay-as-you-go package. |
1002600010 | The server is busy. Please wait and try again. |
1002600011 | Server error. |
1002600999 | Unknown error. |
1002602001 | The start and end points do not have home countries, or a service error occurred. |
1002602002 | Cross-region route planning is not supported. |
1002602003 | The number of start points or end points exceed 100. |
1002602004 | The linear distance between the start point and end point exceeds the upper limit. |
1002602005 | The start point, end point, or waypoint does not support navigation. |
1002602006 | The request point is mapped to the same point on the road. |
let params: navi.RouteParams = {
origins: [{
latitude: 31.98441059206815,
longitude: 118.76625379397866
}],
destination: {
latitude: 30.984410259206815,
longitude: 119.766259397866
},
language: "zh_CN"
};
const result = await navi.getCyclingRoutes(getContext(), params);
console.info("Succeeded in getting cycling routes."); getDrivingMatrix(params: DrivingMatrixParams): Promise<MatrixResult>
Plans the driving routes between multiple locations. This API returns the result asynchronously through a promise.
This function is suitable for high-concurrency scenarios, such as ride-hailing order dispatching. In this context, the function performs a batch calculation for a single request, obtaining the route distance and journey time between multiple departure places and destinations.
1. Driving route planning is limited to locations within a straight-line distance of 2000 kilometers.
2. The number of departure places multiplied by the number of destinations cannot exceed 100.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 4.1.0(11).
System capability: SystemCapability.Map.Core
Start version: 4.1.0(11)
Parameters:
Name | Type | Mandatory | Description |
|---|---|---|---|
params | Yes | Parameters for batch driving route computation. |
Returns:
Type | Description |
|---|---|
Promise<MatrixResult> | MatrixResult object returned through a promise. |
Error codes:
For details about the error codes, please refer to ArkTS API Error Codes.
Error Code | Error Message |
|---|---|
401 | Invalid input parameter. |
1002600001 | System internal error. |
1002600002 | Failed to connect to the Map Kit server. |
1002600003 | App authentication failed. |
1002600004 | The Map permission is not enabled. |
1002600006 | The API call times exceed the quota. |
1002600007 | The API QPS exceeds the quota. |
1002600008 | The API is in arrears. |
1002600009 | The API has not subscribed to any pay-as-you-go package. |
1002600010 | The server is busy. Please wait and try again. |
1002600011 | Server error. |
1002600999 | Unknown error. |
1002602001 | The start and end points do not have home countries, or a service error occurred. |
1002602002 | Cross-region route planning is not supported. |
1002602003 | The number of start points or end points exceed 100. |
1002602004 | The linear distance between the start point and end point exceeds the upper limit. |
1002602005 | The start point, end point, or waypoint does not support navigation. |
1002602006 | The request point is mapped to the same point on the road. |
let params: navi.DrivingMatrixParams = {
"origins": [
{
latitude: 31.9844159206815,
longitude: 118.76625379397866
},
{
latitude: 31.184410259206815,
longitude: 118.366379397866
}
],
"destinations": [{
latitude: 30.98441259206815,
longitude: 119.765379397866
}],
"trafficMode": 2,
"language": "zh_CN"
};
const result = await navi.getDrivingMatrix(params);
console.info("Succeeded in getting driving matrix."); getDrivingMatrix(context: common.Context, params: DrivingMatrixParams): Promise<MatrixResult>
Plans the driving routes between multiple locations. The context can be passed. This API returns the result asynchronously through a promise.
This function is suitable for high-concurrency scenarios, such as ride-hailing order dispatching. In this context, the function performs a batch calculation for a single request, obtaining the route distance and journey time between multiple departure places and destinations.
1. Driving route planning is limited to locations within a straight-line distance of 2000 kilometers.
2. The number of departure places multiplied by the number of destinations cannot exceed 100.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 5.0.0(12).
System capability: SystemCapability.Map.Core
Start version: 5.0.0(12)
Parameters:
Name | Type | Mandatory | Description |
|---|---|---|---|
context | Yes | Context. | |
params | Yes | Parameters for batch driving route computation. |
Returns:
Type | Description |
|---|---|
Promise<MatrixResult> | MatrixResult object returned through a promise. |
Error codes:
For details about the error codes, please refer to ArkTS API Error Codes.
Error Code | Error Message |
|---|---|
401 | Invalid input parameter. |
1002600001 | System internal error. |
1002600002 | Failed to connect to the Map Kit server. |
1002600003 | App authentication failed. |
1002600004 | The Map permission is not enabled. |
1002600006 | The API call times exceed the quota. |
1002600007 | The API QPS exceeds the quota. |
1002600008 | The API is in arrears. |
1002600009 | The API has not subscribed to any pay-as-you-go package. |
1002600010 | The server is busy. Please wait and try again. |
1002600011 | Server error. |
1002600999 | Unknown error. |
1002602001 | The start and end points do not have home countries, or a service error occurred. |
1002602002 | Cross-region route planning is not supported. |
1002602003 | The number of start points or end points exceed 100. |
1002602004 | The linear distance between the start point and end point exceeds the upper limit. |
1002602005 | The start point, end point, or waypoint does not support navigation. |
1002602006 | The request point is mapped to the same point on the road. |
let params: navi.DrivingMatrixParams = {
"origins": [
{
latitude: 31.984410259206815,
longitude: 118.76625379397866
},
{
latitude: 31.904410259206815,
longitude: 118.70625379397866
}
],
"destinations": [{
latitude: 30.9844109206815,
longitude: 119.765379397866
}],
"trafficMode": 2,
"language": "zh_CN"
};
const result = await navi.getDrivingMatrix(getContext(), params);
console.info("Succeeded in getting driving matrix."); getWalkingMatrix(params: MatrixParams): Promise<MatrixResult>
Plans the walking routes between multiple locations. This API returns the result asynchronously through a promise.
This function is suitable for high-concurrency scenarios, such as package delivery. In this context, the function performs a batch calculation for a single request, obtaining the route distance and journey time between multiple departure places and destinations.
1. Walking route planning is limited to locations within a straight-line distance of 150 kilometers.
2. The number of departure places multiplied by the number of destinations cannot exceed 100.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 4.1.0(11).
System capability: SystemCapability.Map.Core
Start version: 4.1.0(11)
Parameters:
Name | Type | Mandatory | Description |
|---|---|---|---|
params | Yes | Parameters for batch walking route computation. |
Returns:
Type | Description |
|---|---|
Promise<MatrixResult> | MatrixResult object returned through a promise. |
Error codes:
For details about the error codes, please refer to ArkTS API Error Codes.
Error Code | Error Message |
|---|---|
401 | Invalid input parameter. |
1002600001 | System internal error. |
1002600002 | Failed to connect to the Map Kit server. |
1002600003 | App authentication failed. |
1002600004 | The Map permission is not enabled. |
1002600006 | The API call times exceed the quota. |
1002600007 | The API QPS exceeds the quota. |
1002600008 | The API is in arrears. |
1002600009 | The API has not subscribed to any pay-as-you-go package. |
1002600010 | The server is busy. Please wait and try again. |
1002600011 | Server error. |
1002600999 | Unknown error. |
1002602001 | The start and end points do not have home countries, or a service error occurred. |
1002602002 | Cross-region route planning is not supported. |
1002602003 | The number of start points or end points exceed 100. |
1002602004 | The linear distance between the start point and end point exceeds the upper limit. |
1002602005 | The start point, end point, or waypoint does not support navigation. |
1002602006 | The request point is mapped to the same point on the road. |
let params: navi.MatrixParams = {
"origins": [
{
latitude: 31.984410259206815,
longitude: 118.76625379397866
},
{
latitude: 31.904410259206815,
longitude: 118.70625379397866
}
],
"destinations": [{
latitude: 30.9844259206815,
longitude: 119.765379397866
}],
"language": "zh_CN"
};
const result = await navi.getWalkingMatrix(params);
console.info("Succeeded in getting walking matrix."); getWalkingMatrix(context: common.Context, params: MatrixParams): Promise<MatrixResult>
Plans the walking routes between multiple locations. The context can be passed. This API returns the result asynchronously through a promise.
This function is suitable for high-concurrency scenarios, such as package delivery. In this context, the function performs a batch calculation for a single request, obtaining the route distance and journey time between multiple departure places and destinations.
1. Walking route planning is limited to locations within a straight-line distance of 150 kilometers.
2. The number of departure places multiplied by the number of destinations cannot exceed 100.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 5.0.0(12).
System capability: SystemCapability.Map.Core
Start version: 5.0.0(12)
Parameters:
Name | Type | Mandatory | Description |
|---|---|---|---|
context | Yes | Context. | |
params | Yes | Parameters for batch walking route computation. |
Returns:
Type | Description |
|---|---|
Promise<MatrixResult> | MatrixResult object returned through a promise. |
Error codes:
For details about the error codes, please refer to ArkTS API Error Codes.
Error Code | Error Message |
|---|---|
401 | Invalid input parameter. |
1002600001 | System internal error. |
1002600002 | Failed to connect to the Map Kit server. |
1002600003 | App authentication failed. |
1002600004 | The Map permission is not enabled. |
1002600006 | The API call times exceed the quota. |
1002600007 | The API QPS exceeds the quota. |
1002600008 | The API is in arrears. |
1002600009 | The API has not subscribed to any pay-as-you-go package. |
1002600010 | The server is busy. Please wait and try again. |
1002600011 | Server error. |
1002600999 | Unknown error. |
1002602001 | The start and end points do not have home countries, or a service error occurred. |
1002602002 | Cross-region route planning is not supported. |
1002602003 | The number of start points or end points exceed 100. |
1002602004 | The linear distance between the start point and end point exceeds the upper limit. |
1002602005 | The start point, end point, or waypoint does not support navigation. |
1002602006 | The request point is mapped to the same point on the road. |
let params: navi.MatrixParams = {
"origins": [
{
latitude: 31.984410259206815,
longitude: 118.76625379397866
},
{
latitude: 31.904410259206815,
longitude: 118.70625379397866
}
],
"destinations": [{
latitude: 30.9810259206815,
longitude: 119.765379397866
}],
"language": "zh_CN"
};
const result = await navi.getWalkingMatrix(getContext(), params);
console.info("Succeeded in getting walking matrix."); getCyclingMatrix(params: MatrixParams): Promise<MatrixResult>
Plans the cycling routes between multiple locations. This API returns the result asynchronously through a promise.
This function is suitable for high-concurrency scenarios, such as package delivery. In this context, the function performs a batch calculation for a single request, obtaining the route distance and journey time between multiple departure places and destinations.
1. Cycling route planning is limited to locations within a straight-line distance of 500 kilometers.
2. The number of departure places multiplied by the number of destinations cannot exceed 100.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 4.1.0(11).
System capability: SystemCapability.Map.Core
Start version: 4.1.0(11)
Parameters:
Name | Type | Mandatory | Description |
|---|---|---|---|
params | Yes | Parameters for batch cycling route computation. |
Returns:
Type | Description |
|---|---|
Promise<MatrixResult> | MatrixResult object returned through a promise. |
Error codes:
For details about the error codes, please refer to ArkTS API Error Codes.
Error Code | Error Message |
|---|---|
401 | Invalid input parameter. |
1002600001 | System internal error. |
1002600002 | Failed to connect to the Map Kit server. |
1002600003 | App authentication failed. |
1002600004 | The Map permission is not enabled. |
1002600006 | The API call times exceed the quota. |
1002600007 | The API QPS exceeds the quota. |
1002600008 | The API is in arrears. |
1002600009 | The API has not subscribed to any pay-as-you-go package. |
1002600010 | The server is busy. Please wait and try again. |
1002600011 | Server error. |
1002600999 | Unknown error. |
1002602001 | The start and end points do not have home countries, or a service error occurred. |
1002602002 | Cross-region route planning is not supported. |
1002602003 | The number of start points or end points exceed 100. |
1002602004 | The linear distance between the start point and end point exceeds the upper limit. |
1002602005 | The start point, end point, or waypoint does not support navigation. |
1002602006 | The request point is mapped to the same point on the road. |
let params: navi.MatrixParams = {
"origins": [
{
latitude: 31.984410259206815,
longitude: 118.76625379397866
},
{
latitude: 31.904410259206815,
longitude: 118.70625379397866
}
],
"destinations": [{
latitude: 30.9841259206815,
longitude: 119.766239397866
}],
"language": "zh_CN"
};
const result = await navi.getCyclingMatrix(params);
console.info("Succeeded in getting cycling matrix."); getCyclingMatrix(context: common.Context, params: MatrixParams): Promise<MatrixResult>
Plans the cycling routes between multiple locations. The context can be passed. This API returns the result asynchronously through a promise.
This function is suitable for high-concurrency scenarios, such as package delivery. In this context, the function performs a batch calculation for a single request, obtaining the route distance and journey time between multiple departure places and destinations.
1. Cycling route planning is limited to locations within a straight-line distance of 500 kilometers.
2. The number of departure places multiplied by the number of destinations cannot exceed 100.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 5.0.0(12).
System capability: SystemCapability.Map.Core
Start version: 5.0.0(12)
Parameters:
Name | Type | Mandatory | Description |
|---|---|---|---|
context | Yes | Context. | |
params | Yes | Parameters for batch cycling route computation. |
Returns:
Type | Description |
|---|---|
Promise<MatrixResult> | MatrixResult object returned through a promise. |
Error codes:
For details about the error codes, please refer to ArkTS API Error Codes.
Error Code | Error Message |
|---|---|
401 | Invalid input parameter. |
1002600001 | System internal error. |
1002600002 | Failed to connect to the Map Kit server. |
1002600003 | App authentication failed. |
1002600004 | The Map permission is not enabled. |
1002600006 | The API call times exceed the quota. |
1002600007 | The API QPS exceeds the quota. |
1002600008 | The API is in arrears. |
1002600009 | The API has not subscribed to any pay-as-you-go package. |
1002600010 | The server is busy. Please wait and try again. |
1002600011 | Server error. |
1002600999 | Unknown error. |
1002602001 | The start and end points do not have home countries, or a service error occurred. |
1002602002 | Cross-region route planning is not supported. |
1002602003 | The number of start points or end points exceed 100. |
1002602004 | The linear distance between the start point and end point exceeds the upper limit. |
1002602005 | The start point, end point, or waypoint does not support navigation. |
1002602006 | The request point is mapped to the same point on the road. |
let params: navi.MatrixParams = {
"origins": [
{
latitude: 31.984410259206815,
longitude: 118.76625379397866
},
{
latitude: 31.904410259206815,
longitude: 118.70625379397866
}
],
"destinations": [{
latitude: 30.98259206815,
longitude: 119.7679397866
}],
"language": "zh_CN"
};
const result = await navi.getCyclingMatrix(getContext(), params);
console.info("Succeeded in getting cycling matrix."); snapToRoads(params: SnapToRoadsParams): Promise<SnapToRoadsResult>
Captures roads based on specified coordinate points to align the user trajectory to the most likely roads that a vehicle was traveling along, and returns a set of coordinate points on the roads. This API returns the result asynchronously through a promise.
The number of coordinate points cannot exceed 100, and the distance between two adjacent coordinate points cannot be greater than 500 meters.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 4.1.0(11).
System capability: SystemCapability.Map.Core
Start version: 4.1.0(11)
Parameters:
Name | Type | Mandatory | Description |
|---|---|---|---|
params | Yes | Parameters for trajectory-based road snapping. |
Returns:
Type | Description |
|---|---|
Promise<SnapToRoadsResult> | SnapToRoadsResult object returned through a promise. |
Error codes:
For details about the error codes, please refer to ArkTS API Error Codes.
Error Code | Error Message |
|---|---|
401 | Invalid input parameter. |
1002600001 | System internal error. |
1002600002 | Failed to connect to the Map Kit server. |
1002600003 | App authentication failed. |
1002600004 | The Map permission is not enabled. |
1002600006 | The API call times exceed the quota. |
1002600007 | The API QPS exceeds the quota. |
1002600008 | The API is in arrears. |
1002600009 | The API has not subscribed to any pay-as-you-go package. |
1002600010 | The server is busy. Please wait and try again. |
1002600011 | Server error. |
1002600999 | Unknown error. |
1002602001 | The start and end points do not have home countries, or a service error occurred. |
1002602002 | Cross-region route planning is not supported. |
1002602003 | The number of start points or end points exceed 100. |
1002602004 | The linear distance between the start point and end point exceeds the upper limit. |
1002602005 | The start point, end point, or waypoint does not support navigation. |
1002602006 | The request point is mapped to the same point on the road. |
let params: navi.SnapToRoadsParams = {
points: [{
latitude: 31.984410259206815,
longitude: 118.76625379397866
}]
};
const result = await navi.snapToRoads(params);
console.info("Succeeded in snapping to roads."); snapToRoads(context: common.Context, params: SnapToRoadsParams): Promise<SnapToRoadsResult>
Captures roads based on specified coordinate points to align the user trajectory to the most likely roads that a vehicle was traveling along, and returns a set of coordinate points on the roads. The context can be passed. This API returns the result asynchronously through a promise.
The number of coordinate points cannot exceed 100, and the distance between two adjacent coordinate points cannot be greater than 500 meters.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 5.0.0(12).
System capability: SystemCapability.Map.Core
Start version: 5.0.0(12)
Parameters:
Name | Type | Mandatory | Description |
|---|---|---|---|
context | Yes | Context. | |
params | Yes | Parameters for trajectory-based road snapping. |
Returns:
Type | Description |
|---|---|
Promise<SnapToRoadsResult> | SnapToRoadsResult object returned through a promise. |
Error codes:
For details about the error codes, please refer to ArkTS API Error Codes.
Error Code | Error Message |
|---|---|
401 | Invalid input parameter. |
1002600001 | System internal error. |
1002600002 | Failed to connect to the Map Kit server. |
1002600003 | App authentication failed. |
1002600004 | The Map permission is not enabled. |
1002600006 | The API call times exceed the quota. |
1002600007 | The API QPS exceeds the quota. |
1002600008 | The API is in arrears. |
1002600009 | The API has not subscribed to any pay-as-you-go package. |
1002600010 | The server is busy. Please wait and try again. |
1002600011 | Server error. |
1002600999 | Unknown error. |
1002602001 | The start and end points do not have home countries, or a service error occurred. |
1002602002 | Cross-region route planning is not supported. |
1002602003 | The number of start points or end points exceed 100. |
1002602004 | The linear distance between the start point and end point exceeds the upper limit. |
1002602005 | The start point, end point, or waypoint does not support navigation. |
1002602006 | The request point is mapped to the same point on the road. |
let params: navi.SnapToRoadsParams = {
points: [{
latitude: 31.984410259206815,
longitude: 118.76625379397866
}]
};
const result = await navi.snapToRoads(getContext(), params);
console.info("Succeeded in snapping to roads."); Defines route planning attributes.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 4.1.0(11).
System capability: SystemCapability.Map.Core
Start version: 4.1.0(11)
Parameters:
Name | Type | Read-only | Optional | Description |
|---|---|---|---|---|
matchType | number | No | Yes | Road snapping type of the departure place and destination. The options are 0 (default), 1, and 3.
|
latitude | number | No | No | Latitude. The value ranges from –90 to 90. |
longitude | number | No | No | Longitude. The value ranges from –180 to 180 (excluded). |
accuracy | number | No | Yes | GPS location accuracy, in meters. |
altitude | number | No | Yes | Altitude, in meters. |
bearing | number | No | Yes | Deviation angle. 0 degrees is due north, and angles increase clockwise. The value range is [0, 360). The default value is 0. Values that fall outside the valid range will be adjusted to values within the range. For instance, the value 361 would be converted to 1, and the value -1 would be converted to 359. |
speed | number | No | Yes | Current driving speed, in meters per second. |
timestamp | number | No | Yes | Timestamp of the current location generation time. |
Defines parameters for planning walking and cycling routes.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 4.1.0(11).
System capability: SystemCapability.Map.Core
Start version: 4.1.0(11)
Parameters:
Name | Type | Read-only | Optional | Description |
|---|---|---|---|---|
origins | Array<RouteCoordinate> | No | No | Departure place coordinate list for road snapping. The last coordinate is the actual departure place. The number of coordinate points cannot exceed 31, and the distance between two adjacent coordinate points must be greater than 1 meter. |
destination | No | No | Destination. | |
language | string | No | Yes | Language of text instructions/descriptions. Currently, only zh_CN (Chinese) and en (English) are supported. If this parameter is not set, the local language will be used. |
avoids | Array<number> | No | Yes | Specified policy for calculating routes. The options are as follows:
The default value is 0. Only two policies are supported for walking and cycling route planning: 0 and 8. Currently, values 16, 32, 128, and 256 are supported only for route planning within the Chinese mainland, and they will be gradually supported in other countries and regions in the future. NOTE: Only policy 1 (Avoid toll roads) and policy 8 (Avoid ferries) can be combined for route planning. |
extension | number | No | Yes | Additional information.
The default value is 0. |
Defines the route planning result.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 4.1.0(11).
System capability: SystemCapability.Map.Core
Start version: 4.1.0(11)
Parameters:
Name | Type | Read-only | Optional | Description |
|---|---|---|---|---|
routes | Array<Route> | No | No | Planned routes from the departure place to the destination. If no routes are available, an empty array will be returned. |
Defines parameters for planning driving routes. This API inherits from RouteParams.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 4.1.0(11).
System capability: SystemCapability.Map.Core
Start version: 4.1.0(11)
Parameters:
Name | Type | Read-only | Optional | Description |
|---|---|---|---|---|
waypoints | Array<mapCommon.LatLng> | No | Yes | Waypoints. You can specify up to 5 waypoints. |
isViaType | boolean | No | Yes | Waypoint type.
|
optimize | boolean | No | Yes | Indicates whether to optimize a waypoint.
The default value is false. |
alternatives | boolean | No | Yes | Indicates whether to return multiple planned routes.
The default value is false. |
departAt | number | No | Yes | Estimated departure time, in seconds since 00:00:00 on January 1, 1970 (UTC). The value must be the current time or a future time. NOTE: If departAt is set to 0, the current time is used. |
trafficMode | number | No | Yes | Time estimation mode. The options are as follows:
The default value is 0. |
Defines planned routes from the departure place to the destination.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 4.1.0(11).
System capability: SystemCapability.Map.Core
Start version: 4.1.0(11)
Parameters:
Name | Type | Read-only | Optional | Description |
|---|---|---|---|---|
steps | Array<RouteStep> | No | No | Route planning information. |
overviewPolyline | Array<mapCommon.LatLng> | No | Yes | Longitude and latitude of the encoded MapPolyline of a route. |
optimizedWaypoints | Array<number> | No | Yes | Index of an optimized waypoint. This parameter is available only when isViaType is set to false and optimize is set to true. |
bounds | Array<CoordinateBound> | No | Yes | Route bounds. |
trafficLightCount | number | No | Yes | Number of traffic lights. |
isDestinationInRestrictedArea | boolean | No | Yes | Indicates whether the destination is in a restricted area.
|
isDestinationInDiffTimeZone | boolean | No | Yes | Indicates whether the time zone of the destination is different from that of the departure place.
|
isCrossCountry | boolean | No | Yes | Indicates whether the route crosses a country boundary.
|
isCrossMultiCountries | boolean | No | Yes | Indicates whether the route crosses multiple country boundaries.
|
hasRestrictedRoad | boolean | No | Yes | Indicates whether the route includes private or restricted roads.
|
hasRoughRoad | boolean | No | Yes | Indicates whether the route includes rough roads.
|
hasFerry | boolean | No | Yes | Indicates whether the route includes ferry.
|
hasTolls | boolean | No | Yes | Indicates whether the route includes toll gates.
|
hasStairs | boolean | No | Yes | Indicates whether the route has stairs.
|
Defines road planning information.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 4.1.0(11).
System capability: SystemCapability.Map.Core
Start version: 4.1.0(11)
Parameters:
Name | Type | Read-only | Optional | Description |
|---|---|---|---|---|
roads | Array<RouteRoad> | No | No | Route section information. |
startLocation | No | No | Longitude and latitude of the departure place. | |
startAddress | string | No | Yes | Detailed address of the departure place. |
endLocation | No | No | Longitude and latitude of the destination. | |
endAddress | string | No | Yes | Detailed address of the destination. |
viaWaypoints | Array<Waypoint> | No | Yes | Waypoint information. |
distance | number | No | Yes | Driving/Walking/Cycling distance, in meters. |
distanceDescription | string | No | Yes | Distance description. |
duration | number | No | Yes | Driving/Walking/Cycling duration, in seconds. |
durationDescription | string | No | Yes | Duration description. |
durationInTraffic | number | No | Yes | Driving/Walking/Cycling duration calculated based on the real-time traffic condition, in seconds. |
durationInTrafficDescription | string | No | Yes | Description of the driving/walking/cycling duration calculated based on the real-time traffic condition. |
Defines route section information.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 4.1.0(11).
System capability: SystemCapability.Map.Core
Start version: 4.1.0(11)
Parameters:
Name | Type | Read-only | Optional | Description |
|---|---|---|---|---|
startLocation | No | No | Longitude and latitude of the departure place. | |
endLocation | No | No | Longitude and latitude of the destination. | |
polyline | Array<mapCommon.LatLng> | No | No | A series of coordinate points on a route section (including coordinates of the departure place and destination). |
distance | number | No | No | Driving/Walking/Cycling distance, in meters. |
distanceDescription | string | No | Yes | Distance description. |
duration | number | No | No | Driving/Walking/Cycling duration, in seconds. |
durationDescription | string | No | Yes | Duration description. |
roadName | string | No | Yes | Road name. |
action | string | No | Yes | Operation to be performed in the current step. The options are as follows:
|
orientation | number | No | Yes | Road direction. The options are as follows:
|
instruction | string | No | Yes | Text instruction. |
trafficSegments | Array<TrafficSegment> | No | Yes | Traffic information. |
Defines route bounds.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 4.1.0(11).
System capability: SystemCapability.Map.Core
Start version: 4.1.0(11)
Parameters:
Name | Type | Read-only | Optional | Description |
|---|---|---|---|---|
northeast | No | No | Coordinates of the northeast corner. | |
southwest | No | No | Coordinates of the southwest corner. |
Defines waypoint information.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 4.1.0(11).
System capability: SystemCapability.Map.Core
Start version: 4.1.0(11)
Parameters:
Name | Type | Read-only | Optional | Description |
|---|---|---|---|---|
location | No | No | Longitude and latitude of a waypoint. | |
stepIndex | number | No | No | Waypoint index in the roads array. |
Defines traffic information.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 4.1.0(11).
System capability: SystemCapability.Map.Core
Start version: 4.1.0(11)
Parameters:
Name | Type | Read-only | Optional | Description |
|---|---|---|---|---|
distance | number | No | No | Driving/Walking/Cycling distance, in meters. |
status | number | No | No | Traffic status. The options are as follows:
|
polyline | Array<mapCommon.LatLng> | No | No | Road section shape coordinates. |
Defines parameters for batch walking and cycling route computation.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 4.1.0(11).
System capability: SystemCapability.Map.Core
Start version: 4.1.0(11)
Parameters:
Name | Type | Read-only | Optional | Description |
|---|---|---|---|---|
origins | Array<RouteCoordinate> | No | No | Longitudes and latitudes of the departure places. A maximum of 100 values are allowed. |
destinations | Array<RouteCoordinate> | No | No | Longitudes and latitudes of the destinations. A maximum of 100 values are allowed. NOTE: 1. Driving route planning, walking route planning, and cycling route planning are limited to locations within a straight-line distance of 2000 kilometers, 150 kilometers, and 500 kilometers, respectively. 2. The number of departure places multiplied by the number of destinations cannot exceed 100. |
language | string | No | Yes | Language of text instructions/descriptions. Currently, only zh_CN (Chinese) and en (English) are supported. If this parameter is not set, the local language will be used. |
avoids | Array<number> | No | Yes | Specified policy for calculating routes. The options are as follows:
The default value is 0. Only two policies are supported for walking and cycling route planning: 0 and 8. All values are supported for driving route planning. Currently, values 16, 32, 128, and 256 are supported only for route planning within the Chinese mainland, and they will be gradually supported in other countries and regions in the future. |
Defines the result of batch route computation.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 4.1.0(11).
System capability: SystemCapability.Map.Core
Start version: 4.1.0(11)
Parameters:
Name | Type | Read-only | Optional | Description |
|---|---|---|---|---|
originAddresses | Array<string> | No | No | Detailed address of the departure place. |
destinationAddresses | Array<string> | No | No | Detailed address of the destination. |
rows | Array<MatrixRow> | No | No | Distances and journey time of routes between departure places and destinations. |
Defines parameters for batch driving route computation. This API inherits from MatrixParams.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 4.1.0(11).
System capability: SystemCapability.Map.Core
Start version: 4.1.0(11)
Parameters:
Name | Type | Read-only | Optional | Description |
|---|---|---|---|---|
departAt | number | No | Yes | Estimated departure time, in seconds since 00:00:00 on January 1, 1970 (UTC). The value must be the current time or a future time. NOTE: If departAt is set to 0, the current time is used. |
trafficMode | number | No | Yes | Time estimation mode. The options are as follows:
The default value is 0. |
Defines distances and journey time of routes between departure places and destinations.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 4.1.0(11).
System capability: SystemCapability.Map.Core
Start version: 4.1.0(11)
Parameters:
Name | Type | Read-only | Optional | Description |
|---|---|---|---|---|
cells | Array<MatrixCell> | No | No | Information about each element in the distance matrix. |
Defines information about each element in the distance matrix.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 4.1.0(11).
System capability: SystemCapability.Map.Core
Start version: 4.1.0(11)
Parameters:
Name | Type | Read-only | Optional | Description |
|---|---|---|---|---|
distance | number | No | Yes | Driving/Walking/Cycling distance, in meters. |
distanceDescription | string | No | Yes | Distance description. |
duration | number | No | Yes | Driving/Walking/Cycling duration, in seconds. |
durationDescription | string | No | Yes | Duration description. |
Defines parameters for trajectory-based road snapping.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 4.1.0(11).
System capability: SystemCapability.Map.Core
Start version: 4.1.0(11)
Parameters:
Name | Type | Read-only | Optional | Description |
|---|---|---|---|---|
points | Array<mapCommon.LatLng> | No | No | Collection of road snapping points. The number of the points cannot exceed 100, and the distance between two adjacent points must be less than or equal to 500 meters. |
Defines the trajectory-based road snapping result.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 4.1.0(11).
System capability: SystemCapability.Map.Core
Start version: 4.1.0(11)
Parameters:
Name | Type | Read-only | Optional | Description |
|---|---|---|---|---|
responseTime | number | No | No | Time required, in milliseconds. |
snappedPoints | Array<SnappedPoint> | No | No | Coordinate points on a road. The number of coordinate points cannot exceed 100, and the distance between two adjacent coordinate points cannot be greater than 500 meters. |
Defines road snapping points.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since API version 4.1.0(11).
System capability: SystemCapability.Map.Core
Start version: 4.1.0(11)
Parameters:
Name | Type | Read-only | Optional | Description |
|---|---|---|---|---|
latitude | number | No | No | Latitude. |
longitude | number | No | No | Longitude. |
roadId | string | No | No | Road ID. |