智能巡航 最后更新时间: 2026年05月29日
功能简介
智能巡航模式 是一种无需设置起点与终点、无需路径规划的轻量级导航引导模式。在驾车过程中,系统会自动播报前方交通设施、电子眼、拥堵路段等实时信息,提升驾驶安全性与体验感。
- 无需算路
- 无需起终点
- 支持语音/视觉提示
- 实时获取交通事件信息
- 巡航模式需联网使用。
- 巡航效果建议在真实车辆行驶或模拟定位环境中体验。
- 巡航模式与导航模式互斥,不可同时运行。
核心 API 使用说明
1. 获取导航实例
import { AMapNaviFactory } from "@amap/amap_lbs_navi";
const context = getContext().getApplicationContext();
this.mAMapNavi = AMapNaviFactory.getAMapNaviInstance(context, 'YOUR_API_KEY');2. 设置巡航监听器(IAimlessModeListener)
实现 IAimlessModeListener 接口以接收各类巡航事件回调:
回调方法说明:
3. 启动/停止智能巡航
启动巡航模式
this.mAMapNavi.startAimlessMode(mode: number);tsthis.mAMapNavi.startAimlessMode(3); // 开启智能播报停止巡航模式
tsthis.mAMapNavi.stopAimlessMode();模式切换规则
由于 导航模式 与 巡航模式 互斥,请遵循以下流程进行切换:
支持模拟测试(可选)
可通过 MockLocationManager 模拟路径行驶,验证巡航逻辑是否正常。
启用模拟定位步骤:
- 设置模拟管理器:
this.mAMapNavi.setMockLocationManager(MockLocationManager.getInstance());- 添加路径计算成功监听:
this.mAMapNavi.addAMapNaviListener({
onCalculateRouteSuccess: () => {
const path = this.mAMapNavi?.getNaviPath();
if (path) {
this.mAMapNavi?.setEmulatorNaviSpeed(10); // 设置模拟速度:10km/h
this.mAMapNavi?.startAimlessMode(3);
this.mAMapNavi?.startMockLocation(path);
}
},
onCalculateRouteFailure: (errorCode) => {
console.error('路径规划失败:', errorCode);
}
});- 发起路径规划请求:
const startList = new ArrayList<INaviLatLng>();
startList.add({ latitude: 40.037530, longitude: 116.417580 });
const endList = new ArrayList<INaviLatLng>();
endList.add({ latitude: 40.035570, longitude: 116.417020 });
const wayPoints = new ArrayList<INaviLatLng>();
this.mAMapNavi.calculateDriveRoute(startList, endList, wayPoints, 0);
