文档管理中心

navi(路径规划)

本模块提供路径规划功能。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

起始版本:4.1.0(11)

导入模块

import { navi } from '@kit.MapKit';

本模块提供以下方法,支持路径规划、批量算路、轨迹绑路功能。

展开

名称

说明

getDrivingRoutes(params: DrivingRouteParams)

驾车路径规划。

getDrivingRoutes(context: common.Context, params: DrivingRouteParams)

驾车路径规划,支持传入Context上下文。

getWalkingRoutes(params: RouteParams)

步行路径规划。

getWalkingRoutes(context: common.Context, params: RouteParams)

步行路径规划,支持传入Context上下文。

getCyclingRoutes(params: RouteParams)

骑行路径规划。

getCyclingRoutes(context: common.Context, params: RouteParams)

骑行路径规划,支持传入Context上下文。

getDrivingMatrix(params: DrivingMatrixParams)

驾车批量算路。

getDrivingMatrix(context: common.Context, params: DrivingMatrixParams)

驾车批量算路,支持传入Context上下文。

getWalkingMatrix(params: MatrixParams)

步行批量算路。

getWalkingMatrix(context: common.Context, params: MatrixParams)

步行批量算路,支持传入Context上下文。

getCyclingMatrix(params: MatrixParams)

骑行批量算路。

getCyclingMatrix(context: common.Context, params: MatrixParams)

骑行批量算路,支持传入Context上下文。

snapToRoads(params: SnapToRoadsParams)

轨迹绑路。

snapToRoads(context: common.Context, params: SnapToRoadsParams)

轨迹绑路,支持传入Context上下文。

本模块提供以下类或接口,支持路径规划、批量算路、轨迹绑路功能。

展开

名称

类型

说明

RouteCoordinate

RouteCoordinate

路线规划属性。

RouteParams

RouteParams

步行、骑行路径规划参数接口。

RouteResult

RouteResult

路径规划的结果。

DrivingRouteParams

DrivingRouteParams

驾车路径规划参数接口。

Route

Route

从起点到目的地的规划路径。

RouteStep

RouteStep

路段规划信息。

RouteRoad

RouteRoad

路线分段信息。

CoordinateBound

CoordinateBound

路线边界范围。

Waypoint

Waypoint

途经点信息。

TrafficSegment

TrafficSegment

路况信息。

MatrixParams

MatrixParams

步行、骑行批量算路参数接口。

MatrixResult

MatrixResult

批量算路的结果。

DrivingMatrixParams

DrivingMatrixParams

驾车批量算路参数接口。

MatrixRow

MatrixRow

origins和destinations两两进行路径规划后计算出来的时长和距离。

MatrixCell

MatrixCell

距离矩阵结果每个单元格的信息。

SnapToRoadsParams

SnapToRoadsParams

轨迹绑路的参数。

SnapToRoadsResult

SnapToRoadsResult

轨迹绑路的结果。

SnappedPoint

SnappedPoint

道路吸附点。

getDrivingRoutes

getDrivingRoutes(params: DrivingRouteParams): Promise<RouteResult>

规划两个地点之间的驾车路线。使用Promise异步回调。

说明
  • 每次调用最多可以返回3条路径。
  • 最多可以指定5个途经点。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力:SystemCapability.Map.Core

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

params

DrivingRouteParams

是

驾车路径规划的参数。

返回值:

展开

类型

说明

Promise<RouteResult>

Promise对象,返回RouteResult。

错误码:

以下错误码的详细介绍请参见地图服务错误码。

展开

错误码ID

错误信息

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

getDrivingRoutes(context: common.Context, params: DrivingRouteParams): Promise<RouteResult>

规划两个地点之间的驾车路线,支持传入Context上下文。使用Promise异步回调。

说明
  • 每次调用最多可以返回3条路径。
  • 最多可以指定5个途经点。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本5.0.0(12)开始,该接口支持在元服务中使用。

系统能力:SystemCapability.Map.Core

起始版本:5.0.0(12)

参数:

展开

参数名

类型

必填

说明

context

common.Context

是

Context上下文。

params

DrivingRouteParams

是

驾车路径规划的参数。

返回值:

展开

类型

说明

Promise<RouteResult>

Promise对象,返回RouteResult。

错误码:

以下错误码的详细介绍请参见地图服务错误码。

展开

错误码ID

错误信息

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

getWalkingRoutes(params: RouteParams): Promise<RouteResult>

规划两个地点之间的步行路线。使用Promise异步回调。

说明

只能规划直线距离150公里内的两个地点步行路线。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力:SystemCapability.Map.Core

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

params

RouteParams

是

步行路径规划的参数。

返回值:

展开

类型

说明

Promise<RouteResult>

Promise对象,返回RouteResult。

错误码:

以下错误码的详细介绍请参见地图服务错误码。

展开

错误码ID

错误信息

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

getWalkingRoutes(context: common.Context, params: RouteParams): Promise<RouteResult>

规划两个地点之间的步行路线,支持传入Context上下文。使用Promise异步回调。

说明

只能在直线距离150公里内规划步行路线。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本5.0.0(12)开始,该接口支持在元服务中使用。

系统能力:SystemCapability.Map.Core

起始版本:5.0.0(12)

参数:

展开

参数名

类型

必填

说明

context

common.Context

是

Context上下文。

params

RouteParams

是

步行路径规划的参数。

返回值:

展开

类型

说明

Promise<RouteResult>

Promise对象,返回RouteResult。

错误码:

以下错误码的详细介绍请参见地图服务错误码。

展开

错误码ID

错误信息

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

getCyclingRoutes(params: RouteParams): Promise<RouteResult>

规划两个地点之间的骑行路线。使用Promise异步回调。

说明

只能在直线距离500公里内规划骑行路线。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力:SystemCapability.Map.Core

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

params

RouteParams

是

骑行路径规划的参数。

返回值:

展开

类型

说明

Promise<RouteResult>

Promise对象,返回RouteResult。

错误码:

以下错误码的详细介绍请参见地图服务错误码。

展开

错误码ID

错误信息

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

getCyclingRoutes(context: common.Context, params: RouteParams): Promise<RouteResult>

规划两个地点之间的骑行路线,支持传入Context上下文。使用Promise异步回调。

说明

只能在直线距离500公里内规划骑行路线。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本5.0.0(12)开始,该接口支持在元服务中使用。

系统能力:SystemCapability.Map.Core

起始版本:5.0.0(12)

参数:

展开

参数名

类型

必填

说明

context

common.Context

是

Context上下文。

params

RouteParams

是

骑行路径规划的参数。

返回值:

展开

类型

说明

Promise<RouteResult>

Promise对象,返回RouteResult。

错误码:

以下错误码的详细介绍请参见地图服务错误码。

展开

错误码ID

错误信息

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

getDrivingMatrix(params: DrivingMatrixParams): Promise<MatrixResult>

规划多个地点之间的驾车路线。使用Promise异步回调。

该功能适用于高并发场景,例如网约车订单调度。在这种情况下,该功能可以计算多个起点和终点之间的路线,并找到网约车订单调度所需的起点和终点。

说明

1. 只能在直线距离2000公里内规划驾车路线。

2. 起点的数量乘以终点的数量不能超过100。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力:SystemCapability.Map.Core

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

params

DrivingMatrixParams

是

驾车批量算路的参数。

返回值:

展开

类型

说明

Promise<MatrixResult>

Promise对象,返回MatrixResult。

错误码:

以下错误码的详细介绍请参见地图服务错误码。

展开

错误码ID

错误信息

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

getDrivingMatrix(context: common.Context, params: DrivingMatrixParams): Promise<MatrixResult>

规划多个地点之间的驾车路线,支持传入Context上下文。使用Promise异步回调。

该功能适用于高并发场景,例如网约车订单调度。在这种情况下,该功能可以计算多个起点和终点之间的路线,并找到网约车订单调度所需的起点和终点。

说明

1. 只能在直线距离2000公里内规划驾车路线。

2. 起点的数量乘以终点的数量不能超过100。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本5.0.0(12)开始,该接口支持在元服务中使用。

系统能力:SystemCapability.Map.Core

起始版本:5.0.0(12)

参数:

展开

参数名

类型

必填

说明

context

common.Context

是

Context上下文。

params

DrivingMatrixParams

是

驾车批量算路的参数。

返回值:

展开

类型

说明

Promise<MatrixResult>

Promise对象,返回MatrixResult。

错误码:

以下错误码的详细介绍请参见地图服务错误码。

展开

错误码ID

错误信息

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

getWalkingMatrix(params: MatrixParams): Promise<MatrixResult>

规划多个地点之间的步行路线。使用Promise异步回调。

该功能适用于高并发场景,例如包裹递送。在这种情况下,该功能可以计算多个起点和终点之间的路线,并找到包裹递送所需的起点和终点。

说明

1. 只能在直线距离150公里内规划步行路线。

2. 起点的数量乘以终点的数量不能超过100。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力:SystemCapability.Map.Core

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

params

MatrixParams

是

步行批量算路的参数。

返回值:

展开

类型

说明

Promise<MatrixResult>

Promise对象,返回MatrixResult。

错误码:

以下错误码的详细介绍请参见地图服务错误码。

展开

错误码ID

错误信息

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

getWalkingMatrix(context: common.Context, params: MatrixParams): Promise<MatrixResult>

规划多个地点之间的步行路线,支持传入Context上下文。使用Promise异步回调。

该功能适用于高并发场景,例如包裹递送。在这种情况下,该功能可以计算多个起点和终点之间的路线,并找到包裹递送所需的起点和终点。

说明

1. 只能在直线距离150公里内规划步行路线。

2. 起点的数量乘以终点的数量不能超过100。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本5.0.0(12)开始,该接口支持在元服务中使用。

系统能力:SystemCapability.Map.Core

起始版本:5.0.0(12)

参数:

展开

参数名

类型

必填

说明

context

common.Context

是

Context上下文。

params

MatrixParams

是

步行批量算路的参数。

返回值:

展开

类型

说明

Promise<MatrixResult>

Promise对象,返回MatrixResult。

错误码:

以下错误码的详细介绍请参见地图服务错误码。

展开

错误码ID

错误信息

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

getCyclingMatrix(params: MatrixParams): Promise<MatrixResult>

规划多个地点之间的骑行路线。使用Promise异步回调。

该功能适用于高并发场景,例如包裹递送。在这种情况下,该功能可以计算多个起点和终点之间的路线,并找到包裹递送所需的起点和终点。

说明

1. 只能在直线距离500公里内规划骑行路线。

2. 起点的数量乘以终点的数量不能超过100。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力:SystemCapability.Map.Core

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

params

MatrixParams

是

骑行批量算路的参数。

返回值:

展开

类型

说明

Promise<MatrixResult>

Promise对象,返回MatrixResult。

错误码:

以下错误码的详细介绍请参见地图服务错误码。

展开

错误码ID

错误信息

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

getCyclingMatrix(context: common.Context, params: MatrixParams): Promise<MatrixResult>

规划多个地点之间的骑行路线,支持传入Context上下文。使用Promise异步回调。

该功能适用于高并发场景,例如包裹递送。在这种情况下,该功能可以计算多个起点和终点之间的路线,并找到包裹递送所需的起点和终点。

说明

1. 只能在直线距离500公里内规划骑行路线。

2. 起点的数量乘以终点的数量不能超过100。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本5.0.0(12)开始,该接口支持在元服务中使用。

系统能力:SystemCapability.Map.Core

起始版本:5.0.0(12)

参数:

展开

参数名

类型

必填

说明

context

common.Context

是

Context上下文。

params

MatrixParams

是

骑行批量算路的参数。

返回值:

展开

类型

说明

Promise<MatrixResult>

Promise对象,返回MatrixResult。

错误码:

以下错误码的详细介绍请参见地图服务错误码。

展开

错误码ID

错误信息

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

snapToRoads(params: SnapToRoadsParams): Promise<SnapToRoadsResult>

基于指定的坐标点捕获道路,将用户轨迹移动到正确的道路,并返回车辆行驶在实际道路上的一组坐标点。使用Promise异步回调。

说明

坐标点的数量不能超过100,并且两个相邻点之间的距离必须小于等于500米。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力:SystemCapability.Map.Core

起始版本:4.1.0(11)

参数:

展开

参数名

类型

必填

说明

params

SnapToRoadsParams

是

轨迹绑路的参数。

返回值:

展开

类型

说明

Promise<SnapToRoadsResult>

Promise对象,返回SnapToRoadsResult。

错误码:

以下错误码的详细介绍请参见地图服务错误码。

展开

错误码ID

错误信息

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

snapToRoads(context: common.Context, params: SnapToRoadsParams): Promise<SnapToRoadsResult>

基于指定的坐标点捕获道路,将用户轨迹移动到正确的道路,并返回车辆行驶在实际道路上的一组坐标点,支持传入Context上下文。使用Promise异步回调。

说明

坐标点的数量不能超过100,并且两个相邻点之间的距离必须小于等于500米。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本5.0.0(12)开始,该接口支持在元服务中使用。

系统能力:SystemCapability.Map.Core

起始版本:5.0.0(12)

参数:

展开

参数名

类型

必填

说明

context

common.Context

是

Context上下文。

params

SnapToRoadsParams

是

轨迹绑路的参数。

返回值:

展开

类型

说明

Promise<SnapToRoadsResult>

Promise对象,返回SnapToRoadsResult。

错误码:

以下错误码的详细介绍请参见地图服务错误码。

展开

错误码ID

错误信息

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.");

RouteCoordinate

路线规划属性。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力:SystemCapability.Map.Core

起始版本:4.1.0(11)

参数:

展开

名称

类型

只读

可选

说明

matchType

number

否

是

起终点绑路类型。

取值包括0、1、3,默认值为0。

  • 0:限制绑路。起点避免绑定封闭、施工、限行、偏好设置所避免的道路,终点避免绑定高速、轮渡、 偏好设置所避免的道路。
  • 1:无限制绑路,不考虑道路本身限制。
  • 3:轨迹绑路,通过origins字段输入连续轨迹点的经纬度进行无限制绑路,只支持起点。

latitude

number

否

否

纬度,取值范围:[-90, 90] 。

longitude

number

否

否

经度,取值范围:[-180, 180) 。

accuracy

number

否

是

GPS定位精度,单位:米。无默认值。

altitude

number

否

是

海拔高度,单位:米。无默认值。

bearing

number

否

是

偏转角度。无默认值。

以正北方向为0度、顺时针方向为正的角度,默认值为0,取值范围:[0, 360)。超出取值范围的值会换算成取值范围内的值,比如361会被换算成1,-1换算为359。

speed

number

否

是

当前行驶速度,单位:米/秒。无默认值。

timestamp

number

否

是

当前定位生成时间的时间戳。无默认值。

RouteParams

步行、骑行路径规划参数接口。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力:SystemCapability.Map.Core

起始版本:4.1.0(11)

参数:

展开

名称

类型

只读

可选

说明

origins

Array<RouteCoordinate>

否

否

道路绑定的起点坐标列表,最后一个坐标是真正的出发地。

坐标点的数量不能超过31个,相邻两个点之间的距离应大于1米。

destination

RouteCoordinate

否

否

目的地。

language

string

否

是

文字指引/描述的语种。目前只支持中文zh_CN和英文en。如果不传,返回地点的当地语言。

avoids

Array<number>

否

是

表示计算出的路径应避免所指示的特性。取值包括:

  • 0:速度快
  • 1:避免收费
  • 2:避免高速
  • 4:距离短
  • 8:避免轮渡
  • 16:躲避拥堵
  • 32:大路优先
  • 64:智能路线
  • 128:高速优先
  • 256:少收费
  • 512:速度流畅

默认值为0。

步行和骑行仅支持两种策略:0和8。

目前设置项16、32、128和256仅在中国大陆的路线规划中支持,后续将在其他国家和地区陆续支持这些设置项。

说明

以上为单独策略,组合策略仅支持1和8:避免收费+避免轮渡。

extension

number

否

是

额外信息。包括:

  • 0:基础路况信息
  • 1:新增路况信息

默认值为0。

RouteResult

路径规划的结果。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力:SystemCapability.Map.Core

起始版本:4.1.0(11)

参数:

展开

名称

类型

只读

可选

说明

routes

Array<Route>

否

否

从起点到目的地的规划路径。如果没有结果,返回空数组。

DrivingRouteParams

驾车路径规划参数接口,继承RouteParams。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力:SystemCapability.Map.Core

起始版本:4.1.0(11)

参数:

展开

名称

类型

只读

可选

说明

waypoints

Array<mapCommon.LatLng>

否

是

途经点。最多可以输入5个途经点。

isViaType

boolean

否

是

途经点类型,是via类型还是stopover类型,默认值为false。

  • false:stopover类型
  • true:via类型
说明

1. stopover类型为经停点,将分段下发路线信息。

2. via类型为经过点,将整段下发路线信息。

optimize

boolean

否

是

是否对途经点进行优化。

  • false:不进行途经点优化
  • true:进行途经点优化

默认值为false。

alternatives

boolean

否

是

是否返回多条规划路线结果。

  • true:返回多条规划路线结果
  • false:返回单条规划路线结果

默认值为false。

departAt

number

否

是

预计出发时间。以自UTC 1970年1月1日午夜以来的秒数为单位。

必须是当前或者未来时间,不能是过去时间。

说明

departAt输入0时,按照当前时间进行处理。

trafficMode

number

否

是

时间预估模型。取值包括:

  • 0:智能预测
  • 1:路况差于历史平均水平
  • 2:路况优于历史平均水平

默认值为0。

Route

从起点到目的地的规划路径。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力:SystemCapability.Map.Core

起始版本:4.1.0(11)

参数:

展开

名称

类型

只读

可选

说明

steps

Array<RouteStep>

否

否

路线规划信息。

overviewPolyline

Array<mapCommon.LatLng>

否

是

表示该路线的编码后的折线经纬度。

optimizedWaypoints

Array<number>

否

是

当isViaType = false且optimize = true 时才会有结果,表示进行路径优化之后途经点的索引。

bounds

Array<CoordinateBound>

否

是

路线边界范围。

trafficLightCount

number

否

是

红绿灯个数。

isDestinationInRestrictedArea

boolean

否

是

终点是否在限制区域。

  • true:在限制区域
  • false:不在限制区域

isDestinationInDiffTimeZone

boolean

否

是

目的地是否在不同时区。

  • true:在不同时区
  • false:在相同时区

isCrossCountry

boolean

否

是

是否穿越国境线。

  • true:穿越国境线
  • false:不穿越国境线

isCrossMultiCountries

boolean

否

是

是否穿越多条国境线。

  • true:穿越多条国境线
  • false:不穿越多条国境线

hasRestrictedRoad

boolean

否

是

此路段是否包含私家/限制用途。

  • true:包含私家/限制用途
  • false:不包含私家/限制用途

hasRoughRoad

boolean

否

是

此路段是否经过崎岖道路。

  • true:经过崎岖道路
  • false:不经过崎岖道路

hasFerry

boolean

否

是

是否途径轮渡。

  • true:途径轮渡
  • false:不途径轮渡

hasTolls

boolean

否

是

此路段是否含收费站。

  • true:含收费站
  • false:不含收费站

hasStairs

boolean

否

是

此路段是否含有阶梯。

  • true:含有阶梯
  • false:不含有阶梯

RouteStep

路段规划信息。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力:SystemCapability.Map.Core

起始版本:4.1.0(11)

参数:

展开

名称

类型

只读

可选

说明

roads

Array<RouteRoad>

否

否

路线分段信息。

startLocation

mapCommon.LatLng

否

否

出发地的经纬度。

startAddress

string

否

是

startLocation对应的地址详情。

endLocation

mapCommon.LatLng

否

否

目的地的经纬度。

endAddress

string

否

是

endLocation对应的地址详情。

viaWaypoints

Array<Waypoint>

否

是

途经点信息。

distance

number

否

是

行驶/步行/骑行距离,单位:米。

distanceDescription

string

否

是

distance的文本描述。

duration

number

否

是

行驶/步行/骑行时长,单位:秒。

durationDescription

string

否

是

duration的文本描述。

durationInTraffic

number

否

是

基于实时路况计算出来的行驶/步行/骑行时长,单位:秒。

durationInTrafficDescription

string

否

是

durationInTraffic的文本描述。

RouteRoad

路线分段信息。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力:SystemCapability.Map.Core

起始版本:4.1.0(11)

参数:

展开

名称

类型

只读

可选

说明

startLocation

mapCommon.LatLng

否

否

出发地的经纬度。

endLocation

mapCommon.LatLng

否

否

目的地的经纬度。

polyline

Array<mapCommon.LatLng>

否

否

此路段的一系列坐标点(包含起点和终点坐标)。

distance

number

否

否

行驶/步行/骑行距离,单位:米。

distanceDescription

string

否

是

distance的文本描述。

duration

number

否

否

行驶/步行/骑行时长,单位:秒。

durationDescription

string

否

是

duration的文本描述。

roadName

string

否

是

路名。

action

string

否

是

当前步骤要执行的操作。取值包括:

  • turn_slight_left:向左微转
  • turn_sharp_left:向左急转
  • turn_left:左转
  • turn_slight_right:向右微转
  • turn_sharp_right:向右急转
  • turn_right:右转
  • straight:直行
  • end:终点
  • waypoint:途经点

orientation

number

否

是

道路方向。取值包括:

  • 0:双向
  • 1:正向
  • 2:反向

instruction

string

否

是

文字指引。

trafficSegments

Array<TrafficSegment>

否

是

路况信息。

CoordinateBound

路线边界范围。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力:SystemCapability.Map.Core

起始版本:4.1.0(11)

参数:

展开

名称

类型

只读

可选

说明

northeast

mapCommon.LatLng

否

否

东北角的位置。

southwest

mapCommon.LatLng

否

否

西南角的位置。

Waypoint

途经点信息。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力:SystemCapability.Map.Core

起始版本:4.1.0(11)

参数:

展开

名称

类型

只读

可选

说明

location

mapCommon.LatLng

否

否

途经点的经纬度。

stepIndex

number

否

否

途经点在roads数组里的索引。

TrafficSegment

路况信息。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力:SystemCapability.Map.Core

起始版本:4.1.0(11)

参数:

展开

名称

类型

只读

可选

说明

distance

number

否

否

行驶/步行/骑行距离,单位:米。

status

number

否

否

路况状态。取值包括:

  • 0:未知
  • 1:畅通
  • 2:缓行
  • 3:拥堵
  • 4:严重拥堵

polyline

Array<mapCommon.LatLng>

否

否

路段的形状坐标。

MatrixParams

步行、骑行批量算路参数接口。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力:SystemCapability.Map.Core

起始版本:4.1.0(11)

参数:

展开

名称

类型

只读

可选

说明

origins

Array<RouteCoordinate>

否

否

起点的经纬度,不能超过100个。

destinations

Array<RouteCoordinate>

否

否

终点的经纬度,不能超过100个。

说明

1. 驾车路线只能在直线距离2000公里内规划;步行路线只能在直线距离150公里内规划;骑行路线只能在直线距离500公里内规划。

2. 起点的数量乘以终点的数量不能超过100。

language

string

否

是

文字指引/描述的语种。目前只支持zh_CN和en。如果不传,返回地点的当地语言。

avoids

Array<number>

否

是

表示计算出的路径应避免所指示的特性。取值包括:

  • 0:速度快
  • 1:避免收费
  • 2:避免高速
  • 4:距离短
  • 8:避免轮渡
  • 16:躲避拥堵
  • 32:大路优先
  • 64:智能路线
  • 128:高速优先
  • 256:少收费

默认值为0。

步行和骑行只支持两种设置项:0和8。

驾车支持所有设置项,但目前设置项16、32、128和256仅在中国大陆的路线规划中支持,后续将在其他国家和地区陆续支持这些设置项。

MatrixResult

批量算路的结果。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力:SystemCapability.Map.Core

起始版本:4.1.0(11)

参数:

展开

名称

类型

只读

可选

说明

originAddresses

Array<string>

否

否

origins的地址详情。

destinationAddresses

Array<string>

否

否

destinations的地址详情。

rows

Array<MatrixRow>

否

否

origins和destinations两两进行路径规划后的计算出来的时长和距离。

DrivingMatrixParams

驾车批量算路参数接口,继承MatrixParams。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力:SystemCapability.Map.Core

起始版本:4.1.0(11)

参数:

展开

名称

类型

只读

可选

说明

departAt

number

否

是

预计出发时间。以自UTC 1970年1月1日午夜以来的秒数为单位。

必须是当前或者未来时间,不能是过去时间。

说明

departAt输入0时,按照当前时间进行处理。

trafficMode

number

否

是

时间预估模型。取值包括:

  • 0:最佳猜测(默认值)。
  • 1:路况差于历史平均水平。
  • 2:路况优于历史平均水平。

默认值为0。

MatrixRow

origins和destinations两两进行路径规划后的计算出来的时长和距离。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力:SystemCapability.Map.Core

起始版本:4.1.0(11)

参数:

展开

名称

类型

只读

可选

说明

cells

Array<MatrixCell>

否

否

距离矩阵结果中每个单元格的信息。

MatrixCell

距离矩阵结果中每个单元格的信息。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力:SystemCapability.Map.Core

起始版本:4.1.0(11)

参数:

展开

名称

类型

只读

可选

说明

distance

number

否

是

行驶/步行/骑行距离,单位:米。

distanceDescription

string

否

是

distance的文本描述。

duration

number

否

是

行驶/步行/骑行时长,单位:秒。

durationDescription

string

否

是

duration的文本描述。

SnapToRoadsParams

轨迹绑路的参数。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力:SystemCapability.Map.Core

起始版本:4.1.0(11)

参数:

展开

名称

类型

只读

可选

说明

points

Array<mapCommon.LatLng>

否

否

道路贴合点集合,不能超过100个,且相邻两个点距离需小于等于500米。

SnapToRoadsResult

轨迹绑路的结果。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力:SystemCapability.Map.Core

起始版本:4.1.0(11)

参数:

展开

名称

类型

只读

可选

说明

responseTime

number

否

否

耗时,单位:毫秒。

snappedPoints

Array<SnappedPoint>

否

否

道路上的坐标点。坐标点的数量不能超过100个,并且两个相邻点之间的距离不能超过500米。

SnappedPoint

道路吸附点。

模型约束:此接口仅可在Stage模型下使用。

元服务API:从版本4.1.0(11)开始,该接口支持在元服务中使用。

系统能力:SystemCapability.Map.Core

起始版本:4.1.0(11)

参数:

展开

名称

类型

只读

可选

说明

latitude

number

否

否

纬度 。

longitude

number

否

否

经度 。

roadId

string

否

否

道路ID。

搜索
请输入您想要搜索的关键词