目录

navi (Route Planning)

This module provides the route planning function.

Since: 4.1.0(11)

Modules to Import

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

getDrivingRoutes

getDrivingRoutes(params: DrivingRouteParams): Promise<RouteResult>

Plans the driving routes between two locations. This API uses a promise to return the result.

  • A maximum of three routes can be returned for each API call.

  • You can specify up to 5 waypoints.

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since version 4.1.0(11).

System capability: SystemCapability.Map.Core

Since: 4.1.0(11)

Parameters:

Name Type Mandatory Description
params DrivingRouteParams Yes Parameters for planning driving routes.

Returns:

Type Description
Promise<RouteResult> Promise used to return RouteResult.

Error codes:

For details about the error codes, please refer to ArkTS API Error Codes.

ID 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.

Example:

let params: navi.DrivingRouteParams = {
  // These coordinates are example data. In practical applications, they should be dynamically obtained through location services or user input.
  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>

Plans the driving routes between two locations. The context can be passed. This API uses a promise to return the result.

  • A maximum of three routes can be returned for each API call.

  • You can specify up to 5 waypoints.

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since version 5.0.0(12).

System capability: SystemCapability.Map.Core

Since: 5.0.0(12)

Parameters:

Name Type Mandatory Description
context common.Context Yes Context.
params DrivingRouteParams Yes Parameters for planning driving routes.

Returns:

Type Description
Promise<RouteResult> Promise used to return RouteResult.

Error codes:

For details about the error codes, please refer to ArkTS API Error Codes.

ID 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.

Example:

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(this.getUIContext().getHostContext(), params);
console.info("Succeeded in getting driving routes.");

getWalkingRoutes

getWalkingRoutes(params: RouteParams): Promise<RouteResult>

Plans the walking routes between two locations. This API uses a promise to return the result.

Walking route planning is limited to two locations within a 150-kilometer straight-line distance.

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since version 4.1.0(11).

System capability: SystemCapability.Map.Core

Since: 4.1.0(11)

Parameters:

Name Type Mandatory Description
params RouteParams Yes Parameters for planning walking routes.

Returns:

Type Description
Promise<RouteResult> Promise used to return RouteResult.

Error codes:

For details about the error codes, please refer to ArkTS API Error Codes.

ID 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.

Example:

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>

Plans the walking routes between two locations. The context can be passed. This API uses a promise to return the result.

Walking route planning is limited to two locations within a 150-kilometer straight-line distance.

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since version 5.0.0(12).

System capability: SystemCapability.Map.Core

Since: 5.0.0(12)

Parameters:

Name Type Mandatory Description
context common.Context Yes Context.
params RouteParams Yes Parameters for planning walking routes.

Returns:

Type Description
Promise<RouteResult> Promise used to return RouteResult.

Error codes:

For details about the error codes, please refer to ArkTS API Error Codes.

ID 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.

Example:

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(this.getUIContext().getHostContext(), params);
console.info("Succeeded in getting cycling routes.");

getCyclingRoutes

getCyclingRoutes(params: RouteParams): Promise<RouteResult>

Plans the cycling routes between two locations. This API uses a promise to return the result.

Cycling route planning is limited to two locations within a 500-kilometer straight-line distance.

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since version 4.1.0(11).

System capability: SystemCapability.Map.Core

Since: 4.1.0(11)

Parameters:

Name Type Mandatory Description
params RouteParams Yes Parameters for planning cycling routes.

Returns:

Type Description
Promise<RouteResult> Promise used to return RouteResult.

Error codes:

For details about the error codes, please refer to ArkTS API Error Codes.

ID 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.

Example:

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>

Plans the cycling routes between two locations. The context can be passed. This API uses a promise to return the result.

Cycling route planning is limited to two locations within a 500-kilometer straight-line distance.

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since version 5.0.0(12).

System capability: SystemCapability.Map.Core

Since: 5.0.0(12)

Parameters:

Name Type Mandatory Description
context common.Context Yes Context.
params RouteParams Yes Parameters for planning cycling routes.

Returns:

Type Description
Promise<RouteResult> Promise used to return RouteResult.

Error codes:

For details about the error codes, please refer to ArkTS API Error Codes.

ID 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.

Example:

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(this.getUIContext().getHostContext(), params);
console.info("Succeeded in getting cycling routes.");

getTransitRoutes

getTransitRoutes(context: common.Context, params: TransitRouteParams): Promise<TransitRouteResult>

Plans the transit routes between two locations. This API is available only in the Chinese mainland. This API allows you to pass context and uses a promise to return the result.

The straight-line distance between the start and end points cannot exceed 100 km if they are in different cities; however, there is no distance limit if they are within the same city.

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since version 5.1.1(19).

System capability: SystemCapability.Map.Core

Since: 5.1.1(19)

Parameters:

Name Type Mandatory Description
context common.Context Yes Context.
params TransitRouteParams Yes Parameters for planning transit routes.

Returns:

Type Description
Promise<TransitRouteResult> Promise used to return TransitRouteResult.

Error codes:

For details about the error codes, please refer to ArkTS API Error Codes.

ID Error Message
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.
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.

Example:

let params: navi.TransitRouteParams = {
  "origin": { "latitude": 39.921619, "longitude": 116.356587 },
  "destination": { "latitude": 39.94161, "longitude": 116.353621 },
  "departureTime": new Date().getTime() / 1000
};
const result = await navi.getTransitRoutes(this.getUIContext().getHostContext(), params);
console.info("Succeeded in getting transit routes.");

getDrivingMatrix

getDrivingMatrix(params: DrivingMatrixParams): Promise<MatrixResult>

Plans the driving routes between multiple locations. This API uses a promise to return the result.

This function is suitable for high-concurrency scenarios, such as ride-hailing order dispatching. In such a case, this function can calculate routes between multiple departure places and destinations, helping identify the exact departure place and destination required for ride-hailing order dispatching.

  1. Driving route planning is limited to two locations within a 2000-kilometer straight-line distance.

  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 version 4.1.0(11).

System capability: SystemCapability.Map.Core

Since: 4.1.0(11)

Parameters:

Name Type Mandatory Description
params DrivingMatrixParams Yes Parameters for batch driving route computation.

Returns:

Type Description
Promise<MatrixResult> Promise used to return MatrixResult.

Error codes:

For details about the error codes, please refer to ArkTS API Error Codes.

ID 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.

Example:

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>

Plans the driving routes between multiple locations. The context can be passed. This API uses a promise to return the result.

This function is suitable for high-concurrency scenarios, such as ride-hailing order dispatching. In such a case, this function can calculate routes between multiple departure places and destinations, helping identify the exact departure place and destination required for ride-hailing order dispatching.

  1. Driving route planning is limited to two locations within a 2000-kilometer straight-line distance.

  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 version 5.0.0(12).

System capability: SystemCapability.Map.Core

Since: 5.0.0(12)

Parameters:

Name Type Mandatory Description
context common.Context Yes Context.
params DrivingMatrixParams Yes Parameters for batch driving route computation.

Returns:

Type Description
Promise<MatrixResult> Promise used to return MatrixResult.

Error codes:

For details about the error codes, please refer to ArkTS API Error Codes.

ID 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.

Example:

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(this.getUIContext().getHostContext(), params);
console.info("Succeeded in getting driving matrix.");

getWalkingMatrix

getWalkingMatrix(params: MatrixParams): Promise<MatrixResult>

Plans the walking routes between multiple locations. This API uses a promise to return the result.

This function is suitable for high-concurrency scenarios, such as parcel delivery. In such a case, this function can calculate routes between multiple departure places and destinations, helping identify the exact departure place and destination required for parcel delivery.

  1. Walking route planning is limited to locations within a 150-kilometer straight-line distance.

  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 version 4.1.0(11).

System capability: SystemCapability.Map.Core

Since: 4.1.0(11)

Parameters:

Name Type Mandatory Description
params MatrixParams Yes Parameters for batch walking route computation.

Returns:

Type Description
Promise<MatrixResult> Promise used to return MatrixResult.

Error codes:

For details about the error codes, please refer to ArkTS API Error Codes.

ID 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.

Example:

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>

Plans the walking routes between multiple locations. The context can be passed. This API uses a promise to return the result.

This function is suitable for high-concurrency scenarios, such as parcel delivery. In such a case, this function can calculate routes between multiple departure places and destinations, helping identify the exact departure place and destination required for parcel delivery.

  1. Walking route planning is limited to locations within a 150-kilometer straight-line distance.

  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 version 5.0.0(12).

System capability: SystemCapability.Map.Core

Since: 5.0.0(12)

Parameters:

Name Type Mandatory Description
context common.Context Yes Context.
params MatrixParams Yes Parameters for batch walking route computation.

Returns:

Type Description
Promise<MatrixResult> Promise used to return MatrixResult.

Error codes:

For details about the error codes, please refer to ArkTS API Error Codes.

ID 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.

Example:

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(this.getUIContext().getHostContext(), params);
console.info("Succeeded in getting walking matrix.");

getCyclingMatrix

getCyclingMatrix(params: MatrixParams): Promise<MatrixResult>

Plans the cycling routes between multiple locations. This API uses a promise to return the result.

This function is suitable for high-concurrency scenarios, such as parcel delivery. In such a case, this function can calculate routes between multiple departure places and destinations, helping identify the exact departure place and destination required for parcel delivery.

  1. Cycling route planning is limited to locations within a 500-kilometer straight-line distance.

  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 version 4.1.0(11).

System capability: SystemCapability.Map.Core

Since: 4.1.0(11)

Parameters:

Name Type Mandatory Description
params MatrixParams Yes Parameters for batch cycling route computation.

Returns:

Type Description
Promise<MatrixResult> Promise used to return MatrixResult.

Error codes:

For details about the error codes, please refer to ArkTS API Error Codes.

ID 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.

Example:

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>

Plans the cycling routes between multiple locations. The context can be passed. This API uses a promise to return the result.

This function is suitable for high-concurrency scenarios, such as parcel delivery. In such a case, this function can calculate routes between multiple departure places and destinations, helping identify the exact departure place and destination required for parcel delivery.

  1. Cycling route planning is limited to locations within a 500-kilometer straight-line distance.

  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 version 5.0.0(12).

System capability: SystemCapability.Map.Core

Since: 5.0.0(12)

Parameters:

Name Type Mandatory Description
context common.Context Yes Context.
params MatrixParams Yes Parameters for batch cycling route computation.

Returns:

Type Description
Promise<MatrixResult> Promise used to return MatrixResult.

Error codes:

For details about the error codes, please refer to ArkTS API Error Codes.

ID 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.

Example:

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(this.getUIContext().getHostContext(), params);
console.info("Succeeded in getting cycling matrix.");

snapToRoads

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 uses a promise to return the result.

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 version 4.1.0(11).

System capability: SystemCapability.Map.Core

Since: 4.1.0(11)

Parameters:

Name Type Mandatory Description
params SnapToRoadsParams Yes Parameters for trajectory-based road snapping.

Returns:

Type Description
Promise<SnapToRoadsResult> Promise used to return SnapToRoadsResult.

Error codes:

For details about the error codes, please refer to ArkTS API Error Codes.

ID 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.

Example:

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>

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 uses a promise to return the result.

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 version 5.0.0(12).

System capability: SystemCapability.Map.Core

Since: 5.0.0(12)

Parameters:

Name Type Mandatory Description
context common.Context Yes Context.
params SnapToRoadsParams Yes Parameters for trajectory-based road snapping.

Returns:

Type Description
Promise<SnapToRoadsResult> Promise used to return SnapToRoadsResult.

Error codes:

For details about the error codes, please refer to ArkTS API Error Codes.

ID 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.

Example:

let params: navi.SnapToRoadsParams = {
  points: [{
    latitude: 31.984410259206815,
    longitude: 118.76625379397866
  }]
};
const result = await navi.snapToRoads(this.getUIContext().getHostContext(), params);
console.info("Succeeded in snapping to roads.");

RouteCoordinate

Defines location coordinates used in route planning, such as the departure place and 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 version 4.1.0(11).

System capability: SystemCapability.Map.Core

Since: 4.1.0(11)

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.

0: restricted snapping. Departure places are not snapped to closed roads, roads under construction, traffic restricted roads, and roads set to avoid, and destinations are not snapped to highways, ferries, and roads set to avoid.

1: unlimited snapping.

3: trajectory-based snapping. You can pass the longitude-latitude coordinates of consecutive trajectory points via the origins parameter for unlimited snapping. This value is supported only for the departure place.

latitude number No No Latitude, in degrees. The value range is [-90, 90].
longitude number No No Longitude, in degrees. The value range is [-180, 180).
accuracy number No Yes GPS location accuracy, in meters. This parameter does not have a default value.
altitude number No Yes Altitude, in meters. This parameter does not have a default value.
bearing number No Yes

Bearing delta, in degrees.

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 m/s. This parameter does not have a default value.
timestamp number No Yes Timestamp of the current location generation time. This parameter does not have a default value.

RouteParams

Defines parameters for planning walking, cycling, and driving 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 version 4.1.0(11).

System capability: SystemCapability.Map.Core

Since: 4.1.0(11)

Name Type Read-Only Optional Description
origins Array<RouteCoordinate> No No

List of coordinates of road-snapped departure points.

The number of coordinate points cannot exceed 31, and the distance between two adjacent coordinate points must be greater than 1 meter.

destination RouteCoordinate No No

Destination.

Note:

If waypoints are not set, the coordinates of the departure place and destination cannot be the same.

language string No Yes Language of text instructions/descriptions. Currently, only zh_CN (Chinese) and en (English) are supported. If this parameter is not passed, the local language will be used.
avoids Array<number> No Yes

Route calculation policy. The options are as follows:

0: Fastest route.

1: Avoid tolls.

2: Avoid highways.

4: Shortest distance.

8: Avoid ferries.

16: Avoid congested roads.

32: Prioritize major roads.

64: Smart route.

128: Prioritize highways.

256: Minimize tolls.

512: Smooth speed.

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:

The preceding are independent policies. For driving route planning, only policies 1 (avoid tolls) and 8 (avoid ferries) are supported in combination. If any other combination is passed, policy 64 (smart route) will be used.

extension number No Yes

Additional information. The options are as follows:

0: Basic traffic condition.

1: new traffic condition.

The default value is 0.

RouteResult

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 version 4.1.0(11).

System capability: SystemCapability.Map.Core

Since: 4.1.0(11)

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.

DrivingRouteParams

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 version 4.1.0(11).

System capability: SystemCapability.Map.Core

Since: 4.1.0(11)

Name Type Read-Only Optional Description
waypoints Array<mapCommon.LatLng> No Yes Waypoints. A maximum of five waypoints are supported. Invalid values are not processed.
isViaType boolean No Yes

Waypoint type. Invalid values are not processed.

- false: stopover (default value)

- true: via

Note:

1. The stopover type indicates a waypoint stop. The route information will be returned by segment.

2. The via type indicates a pass-through point. The complete route information will be returned as a whole.

optimize boolean No Yes

Indicates whether to optimize waypoints. Invalid values are not processed.

- false: Waypoint optimization is disabled. The original order is preserved, and waypoints are returned in the input order.

- true: Waypoint optimization is enabled. An intelligent optimization algorithm is applied, and waypoints are returned based on their proximity to the departure place to maximize route planning efficiency.

The default value is false.

alternatives boolean No Yes

Indicates whether to return multiple planned routes. Invalid values are not processed.

- true: yes

- false: no. (Only one planned route is returned.)

The default value is false.

departAt number No Yes

Estimated departure time, in seconds since 00:00:00 on January 1, 1970 (UTC). Invalid values are not processed.

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 model. Invalid values are not processed. The options are as follows:

0: Intelligent prediction.

1: Traffic conditions are worse than the historical average.

2: Traffic conditions are better than the historical average.

The default value is 0.

Route

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 version 4.1.0(11).

System capability: SystemCapability.Map.Core

Since: 4.1.0(11)

Name Type Read-Only Optional Description
steps Array<RouteStep> No No Route planning information.
overviewPolyline Array<mapCommon.LatLng> No Yes Encoded polyline latitude and longitude coordinates of the route.
optimizedWaypoints Array<number> No Yes Indexes of optimized waypoints. 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. The default value is 0.
isDestinationInRestrictedArea boolean No Yes

Indicates whether the destination is in a restricted area. The default value is false.

- true: yes

- false: no

isDestinationInDiffTimeZone boolean No Yes

Indicates whether the destination is in a different time zone. The default value is false.

- true: yes

- false: no

isCrossCountry boolean No Yes

Indicates whether the route crosses a national border. The default value is false.

- true: yes

- false: no

isCrossMultiCountries boolean No Yes

Indicates whether the route crosses multiple national borders. The default value is false.

- true: yes

- false: no

hasRestrictedRoad boolean No Yes

Indicates whether the route includes private or restricted-use roads. The default value is false.

- true: yes

- false: no

hasRoughRoad boolean No Yes

Indicates whether the route includes rough roads. The default value is false.

- true: yes

- false: no

hasFerry boolean No Yes

Indicates whether the route includes ferry. The default value is false.

- true: yes

- false: no

hasTolls boolean No Yes

Indicates whether the route includes toll stations. The default value is false.

- true: yes

- false: no

hasStairs boolean No Yes

Indicates whether the route includes stairs. The default value is false.

- true: yes

- false: no

RouteStep

Defines route section 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 version 4.1.0(11).

System capability: SystemCapability.Map.Core

Since: 4.1.0(11)

Name Type Read-Only Optional Description
roads Array<RouteRoad> No No Route section information.
startLocation mapCommon.LatLng No No Longitude and latitude of the departure place.
startAddress string No Yes Detailed address of the departure place.
endLocation mapCommon.LatLng 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. The default value is 0.
distanceDescription string No Yes Distance description.
duration number No Yes Driving/Walking/Cycling duration, in seconds. The default value is 0.
durationDescription string No Yes Duration description.
durationInTraffic number No Yes Driving/Walking/Cycling duration calculated based on the real-time traffic condition, in seconds. The default value is 0.
durationInTrafficDescription string No Yes Description of the driving/walking/cycling duration calculated based on the real-time traffic condition.

RouteRoad

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 version 4.1.0(11).

System capability: SystemCapability.Map.Core

Since: 4.1.0(11)

Name Type Read-Only Optional Description
startLocation mapCommon.LatLng No No Longitude and latitude of the departure place.
endLocation mapCommon.LatLng 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:

- turn_slight_left: slight left turn

- turn_sharp_left: sharp left turn

- turn_left: left turn

- turn_slight_right: slight right turn

- turn_sharp_right: sharp right turn

- turn_right: right turn

- straight: straight

- end: destination

- waypoint: waypoint

orientation number No Yes

Road direction. The default value is 0. The options are as follows:

0: bidirectional

1: forward direction

2: reverse direction

instruction string No Yes Text instruction.
trafficSegments Array<TrafficSegment> No Yes Traffic information.

CoordinateBound

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 version 4.1.0(11).

System capability: SystemCapability.Map.Core

Since: 4.1.0(11)

Name Type Read-Only Optional Description
northeast mapCommon.LatLng No No Coordinates of the northeast corner.
southwest mapCommon.LatLng No No Coordinates of the southwest corner.

Waypoint

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 version 4.1.0(11).

System capability: SystemCapability.Map.Core

Since: 4.1.0(11)

Name Type Read-Only Optional Description
location mapCommon.LatLng No No Longitude and latitude of a waypoint.
stepIndex number No No Waypoint index in the roads array.

TrafficSegment

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 version 4.1.0(11).

System capability: SystemCapability.Map.Core

Since: 4.1.0(11)

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:

0: unknown

1: smooth

2: slow

3: congested

4: extremely congested

polyline Array<mapCommon.LatLng> No No Road section shape coordinates.

MatrixParams

Defines parameters for batch walking, cycling, and driving 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 version 4.1.0(11).

System capability: SystemCapability.Map.Core

Since: 4.1.0(11)

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 passed, the local language will be used.
avoids Array<number> No Yes

Route calculation policy. The options are as follows:

0: Fastest route.

1: Avoid tolls.

2: Avoid highways.

4: Shortest distance.

8: Avoid ferries.

16: Avoid congested roads.

32: Prioritize major roads.

64: Smart route.

128: Prioritize highways.

256: Minimize tolls.

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.

TransitRouteParams

Defines parameters for transit 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 version 5.1.1(19).

System capability: SystemCapability.Map.Core

Since: 5.1.1(19)

Name Type Read-Only Optional Description
origin RouteCoordinate No No Longitude and latitude of the departure place.
destination RouteCoordinate No No

Longitude and latitude of the destination.

Note:

The longitude and latitude of the departure place cannot be the same as those of the destination.

departureTime 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.
preference number No Yes

Preference setting. The options are as follows:

0: recommended (default value)

1: subway preferred

2: less walking

3: fewer transfers

4: shorter time

5: no subway

The default value is 0.

TransitRouteResult

Defines the transit 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 version 5.1.1(19).

System capability: SystemCapability.Map.Core

Since: 5.1.1(19)

Name Type Read-Only Optional Description
routes TransitRoute[] No Yes List of possible routes.

TransitRoute

Defines the transit route.

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since version 5.1.1(19).

System capability: SystemCapability.Map.Core

Since: 5.1.1(19)

Name Type Read-Only Optional Description
id string No No Route ID.
sections TransitRouteSection[] No No List of transit routes and pedestrian sections.
busSortInfo BusSortInfo No Yes Route planning summary information.

BusSortInfo

Defines the route planning summary 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 version 5.1.1(19).

System capability: SystemCapability.Map.Core

Since: 5.1.1(19)

Name Type Read-Only Optional Description
totalCost number No Yes Total duration, in seconds.
walkLength number No Yes Walking distance, in meters.
transferNum number No Yes Number of transfers.
fee number No Yes Fee. This parameter is reserved and is not used currently.
score number No Yes Score for recommendation. The score is a weighted value calculated based on the travel time, walking distance, number of transfers, number of stops, and route type (bus-only, subway-only, or mixed). The system sorts routes by their scores and recommends the higher-scoring options. This parameter is reserved and is not used currently.
routeId string No Yes Route ID.
currency string No Yes Currency of the payment. This parameter is reserved and is not used currently.
arrivalTime number No Yes Earliest arrival time, in seconds.
routeDesc number No Yes

Route label. The options are as follows:

0: normal

1: outside service hours

2: risk of missing the last service of the day

This parameter is reserved and is not used currently.

TransitRouteSection

Defines the transit route and pedestrian section.

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since version 5.1.1(19).

System capability: SystemCapability.Map.Core

Since: 5.1.1(19)

Name Type Read-Only Optional Description
type string No No

Section type. The options are as follows:

- pedestrian

- transit

pedestrianSection PedestrianSection No Yes Pedestrian section.
transitSection TransitSection No Yes Transit section.

PedestrianSection

Defines the pedestrian section in a route.

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since version 5.1.1(19).

System capability: SystemCapability.Map.Core

Since: 5.1.1(19)

Name Type Read-Only Optional Description
id string No No Unique ID of a pedestrian section.
type string No No Type of a pedestrian section, which is used by an app. The value is always pedestrian.
arrival PedestrianDepartureArrival No No End point of a pedestrian section.
departure PedestrianDepartureArrival No No Start point of a pedestrian section.
language string No Yes Local language (if available), in BCP 47 format.
passthrough Passthrough[] No Yes

List of pass-through waypoints on the section. Each requested waypoint is displayed as passThrough=true in the response. Waypoints appear in the closest non-direct route and are traversed in the order specified in the request.

This parameter is reserved and is not used currently.

polyline mapCommon.LatLng[] No Yes Route shape coordinates.
travelSummary BaseSummary No Yes Set of key attributes (for example, duration and length), only for the travel between the departure place and destination.

PedestrianDepartureArrival

Defines the start and end points of a pedestrian route.

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since version 5.1.1(19).

System capability: SystemCapability.Map.Core

Since: 5.1.1(19)

Name Type Read-Only Optional Description
place Place No No Place on the pedestrian route.
time number No Yes Estimated departure time, measured in seconds since January 1, 1970 00:00:00 UTC.

Passthrough

Defines a place that a route passes through.

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since version 5.1.1(19).

System capability: SystemCapability.Map.Core

Since: 5.1.1(19)

Name Type Read-Only Optional Description
place Place No No Departure/Arrival place.
offset number No Yes Coordinate index of a waypoint.

Place

Defines a common place related to a route.

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since version 5.1.1(19).

System capability: SystemCapability.Map.Core

Since: 5.1.1(19)

Name Type Read-Only Optional Description
location mapCommon.LatLng No No Coordinates of a place.
type string No No

Place type. The options are as follows:

- accessPoint: walking access point.

- station: public transport station.

name string No Yes Place name.

BaseSummary

Defines the set of route key 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 version 5.1.1(19).

System capability: SystemCapability.Map.Core

Since: 5.1.1(19)

Name Type Read-Only Optional Description
duration number No No Duration, in seconds.
length number No No Distance, in meters.
waitTime number No Yes Waiting time, in seconds.

TransitSection

Defines a transit section. It contains departure, arrival, and transport 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 version 5.1.1(19).

System capability: SystemCapability.Map.Core

Since: 5.1.1(19)

Name Type Read-Only Optional Description
id string No No Unique ID of a transit section. This parameter is reserved and is not used currently.
type string No No

The value can be pedestrian or transit.

pedestrian: walking.

transit: non-walking.

arrival TransitArrival No No Transit arrival.
departure TransitDeparture No No Transit departure.
intermediateStops TransitStop[] No Yes

Intermediate stops between the departure place and destination of the transit section.

If the information is unavailable or not requested, this parameter may be missing.

language string No Yes Local language (if available), in BCP 47 format. This parameter is reserved and is not used currently.
passthrough Passthrough[] No Yes

List of pass-through waypoints on the section. Each requested waypoint is displayed as passThrough=true in the response. Waypoints appear in the closest non-direct route and are traversed in the order specified in the request.

This parameter is reserved and is not used currently.

polyline mapCommon.LatLng[] No Yes Route shape coordinates.
transport TransitTransport No Yes Transit route information.
travelSummary BaseSummary No Yes Set of key attributes (for example, duration and length), only for the travel between the departure place and destination. Pre-operations and post-operations are not included.
extraTransitSection ExtraTransitSection[] No Yes Alternative public transport routes between the same departure place and destination.
sectionDesc number No Yes

Route label. The options are as follows:

0: normal

1: outside service hours

2: risk of missing the last service of the day

This parameter is reserved and is not used currently.

firstVehicleHour number No Yes First bus/subway time, in seconds.
finalVehicleHour number No Yes Last bus/subway time, in seconds.
stopOffset number No Yes Time offset from the first station to the boarding or transfer station, in seconds.

TransitArrival

Defines transit arrival.

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since version 5.1.1(19).

System capability: SystemCapability.Map.Core

Since: 5.1.1(19)

Name Type Read-Only Optional Description
place Place No No Destination.
delay number No Yes Cumulative delay from the planned arrival time, in seconds. This parameter is reserved and is not used currently.
time number No Yes Estimated time of arrival at the transit station, measured in seconds since January 1, 1970 00:00:00 UTC. The unit is seconds.
exit TransitEntranceExit No Yes Exit of a transit station.

TransitDeparture

Defines transit departure.

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since version 5.1.1(19).

System capability: SystemCapability.Map.Core

Since: 5.1.1(19)

Name Type Read-Only Optional Description
place Place No No Departure place.
delay number No Yes Cumulative delay from the planned arrival time, in seconds. This parameter is reserved and is not used currently.
time number No Yes Estimated time of departure from the transit station, measured in seconds since January 1, 1970 00:00:00 UTC. The unit is seconds.
entrance TransitEntranceExit No Yes Entrance of a transit station.

TransitEntranceExit

Defines the transit station entrance or exit.

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since version 5.1.1(19).

System capability: SystemCapability.Map.Core

Since: 5.1.1(19)

Name Type Read-Only Optional Description
name string No No Entrance or exit ID.
location mapCommon.LatLng No No Coordinates of a place.

TransitStop

Defines a transit stop.

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since version 5.1.1(19).

System capability: SystemCapability.Map.Core

Since: 5.1.1(19)

Name Type Read-Only Optional Description
departure TransitDeparture No No Transit departure.
duration number No Yes Stop duration at a transfer stop. If it is not set, the vehicle will depart immediately once passengers are onboard.

TransitTransport

Defines the transit route 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 version 5.1.1(19).

System capability: SystemCapability.Map.Core

Since: 5.1.1(19)

Name Type Read-Only Optional Description
mode TransitMode No No Transit mode.
category string No Yes Human-recognizable vehicle type (such as the bus, gondola, tram, and train).
color string No Yes Background color of a public transport route.
headsign string No Yes Transit route sign.
name string No Yes Transit route name.
textColor string No Yes Color of the public transport name.

ExtraTransitSection

Defines the extra transit 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 version 5.1.1(19).

System capability: SystemCapability.Map.Core

Since: 5.1.1(19)

Name Type Read-Only Optional Description
intermediateStops TransitStop[] No No Intermediate stops between the departure place and destination of the transit section. If the information is unavailable or not requested, this parameter may be missing.
polyline mapCommon.LatLng[] No No Route shape coordinates.
transport TransitTransport No No Transit route information.
travelSummary BaseSummary No No Set of key attributes (for example, duration and length), only for the travel between the departure place and destination. Pre-operations and post-operations are not included.
firstVehicleHour number No Yes First bus/subway time, in seconds.
finalVehicleHour number No Yes Last bus/subway time, in seconds.
stopOffset number No Yes Time offset from the first station to the boarding or transfer station, in seconds.

TransitMode

Enumerates the transit modes.

Model restriction: This API can be used only in the stage model.

Atomic service API: This API can be used in atomic services since version 5.1.1(19).

System capability: SystemCapability.Map.Core

Since: 5.1.1(19)

Name Value Description
BUS 'bus' Bus.
SUBWAY 'subway' Subway.

MatrixResult

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 version 4.1.0(11).

System capability: SystemCapability.Map.Core

Since: 4.1.0(11)

Name Type Read-Only Optional Description
originAddresses Array<string> No No Detailed addresses of the departure places.
destinationAddresses Array<string> No No Detailed addresses of the destinations.
rows Array<MatrixRow> No No Distance and journey time of routes between departure places and destinations.

DrivingMatrixParams

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 version 4.1.0(11).

System capability: SystemCapability.Map.Core

Since: 4.1.0(11)

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:

0: best guess (default value).

1: Traffic conditions are worse than the historical average.

2: Traffic conditions are better than the historical average.

The default value is 0.

MatrixRow

Defines the distance 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 version 4.1.0(11).

System capability: SystemCapability.Map.Core

Since: 4.1.0(11)

Name Type Read-Only Optional Description
cells Array<MatrixCell> No No Information about each cell in the distance matrix.

MatrixCell

Defines the information about each cell 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 version 4.1.0(11).

System capability: SystemCapability.Map.Core

Since: 4.1.0(11)

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.

SnapToRoadsParams

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 version 4.1.0(11).

System capability: SystemCapability.Map.Core

Since: 4.1.0(11)

Name Type Read-Only Optional Description
points Array<mapCommon.LatLng> No No Collection of road snapping points. The number of points ranges from 1 to 100, and the distance between adjacent points must be less than or equal to 500 meters.

SnapToRoadsResult

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 version 4.1.0(11).

System capability: SystemCapability.Map.Core

Since: 4.1.0(11)

Name Type Read-Only Optional Description
responseTime number No No Response time, in ms.
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.

SnappedPoint

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 version 4.1.0(11).

System capability: SystemCapability.Map.Core

Since: 4.1.0(11)

Name Type Read-Only Optional Description
latitude number No No Latitude.
longitude number No No Longitude.
roadId string No No Road ID.