百度地图开放平台
/ 路线规划
更新时间:2026/02/27 14:52

路线规划

1. 构造 RoutePlanOption

代码
// 起终点位置
let startPt: RouteNodeInfo = new RouteNodeInfo()
let endPt: RouteNodeInfo = new RouteNodeInfo()
startPt.location = new LatLng(40.048241,116.296165)
endPt.location = new LatLng(40.04721,116.316372)
// 构造 RoutePlanOption ,设置起终点
let param: RoutePlanOption = new RoutePlanOption().startNodeInfo(startPt).endNodeInfo(endPt)

2. 发起路线规划

代码
service.routePlanService().routePlanWithRouteNode(param,new Object({
//引擎开始路线规划
onRoutePlanStart: () => {
},
// 正常规划成功
onRoutePlanSuccess: () => {
// 展示路线
service.routePlanService().displayRoutePlanResult()
},
// 正常规划失败
onRoutePlanFail: (error: RoutePlanError) => {
}
}) as IRoutePlanListener)

本篇文章对您是否有帮助?

使用中遇到问题?查看常见问题提交工单