Appearance
Navigation
说明
Navigation 是一个导航插件,用于实现路线渲染和导航功能。
构造函数
typescript
new Navigation(bmap: BMap, options?: Partial<NavigationConfig>);
参数
参数 | 类型 | 说明 | 默认值 |
---|---|---|---|
bmap | BMap | 地图实例 | - |
options | Partial<NavigationConfig> | 导航配置项 | - |
NavigationConfig 配置项
参数 | 类型 | 说明 | 默认值 |
---|---|---|---|
path | Partial<PathConfig> | 路线的参数 | - |
cheapMaximumDistance | number | 吸附路线的最大偏移距离 | - |
startPoi | Partial<PoiOptions2> | 起点POI配置 | - |
detachStartPoi | Partial<PoiOptions2> | 游离起点POI配置 | - |
positionNavigation | Partial<PositionNavigationConfig> | 位置导航配置 | - |
needStartPoi | boolean | 是否需要起点POI | false |
offsetY | number | 相机偏移距离 | 150 |
directionEmitThreshold | number | 方向变化的提前播报阈值 | 5 |
disablePathAnimation | boolean | 路线移动中是否禁用相机动画 | false |
disablePathRotate | boolean | 路线移动中是否禁用相机旋转 | false |
disablePathShorten | boolean | 路线是否随着POI缩短 | false |
speed | number | 动画速度 | 1 |
roadData | RoadData2[] | 路网数据 | [] |
runAnimationMaxTime | number | 动画最大运行时间 | 1 |
navigationCameraBasic | number | 导航相机基础参数 | 45 |
返回值
Navigation 导航插件实例
属性
path
- 类型:
Path | null
- 默认值:
null
当前导航路径实例
currentPathPosition
- 类型:
[number, number] | null
- 默认值:
null
起点所在的当前位置,平移前坐标
方法
pauseAnimation
typescript
pauseAnimation(): void;
暂停导航动画
参数
无
返回值
无
continueAnimation
typescript
continueAnimation(): void;
继续导航动画
参数
无
返回值
无
clearPath
typescript
clearPath(): void;
清除导航路径
参数
无
返回值
无
addPath
typescript
addPath(paths: PathData2): void;
添加导航路径
参数
参数 | 类型 | 说明 | 默认值 |
---|---|---|---|
paths | PathData2 | 导航路径数据 | - |
返回值
无
toPosition
typescript
toPosition(floor: string, pos: [number, number]): void;
根据定位实时导航
参数
参数 | 类型 | 说明 | 默认值 |
---|---|---|---|
floor | string | 楼层名称 | - |
pos | [number, number] | 位置坐标 | - |
返回值
无
startSimulation
typescript
startSimulation(): void;
开始模拟导航
参数
无
返回值
无
setSimulationSpeed
typescript
setSimulationSpeed(speed: number): void;
修改模拟导航的移动速度
参数
参数 | 类型 | 说明 | 默认值 |
---|---|---|---|
speed | number | 移动速度 | - |
返回值
无
dispose
typescript
dispose(): void;
重置导航状态,包括暂停动画、重置导航状态和起点POI位置
参数
无
返回值
无
resetStatus
typescript
resetStatus(): void;
重置导航状态,包括暂停动画、重置导航状态和起点POI位置
参数
无
返回值
无
setCurPathIndex
typescript
setCurPathIndex(index: number): void;
设置当前导航路径索引,在地图切换楼层之后,应该跟随着调用这个方法,切换地图上的路线
参数
参数 | 类型 | 说明 | 默认值 |
---|---|---|---|
index | number | 要切换到的路径索引 | - |
返回值
无
dispose
typescript
dispose(): void;
销毁导航插件实例
在bmap销毁时,会自动调用dispose方法,无需手动调用
参数
无
返回值
无
事件
fetch-road-status
typescript
(event: "fetch-road-status", args: { status: boolean }): void;
获取路径状态事件
参数
参数 | 类型 | 说明 | 默认值 |
---|---|---|---|
status | boolean | 获取状态 | - |
path-animation
typescript
(event: "path-animation", args: { pathIndex: number }): void;
路径动画事件
参数
参数 | 类型 | 说明 | 默认值 |
---|---|---|---|
pathIndex | number | 当前动画路径索引 | - |
path-animation-end
typescript
(event: "path-animation-end", args: {}): void;
路径动画结束事件
参数
无
render-path
typescript
(event: "render-path", args: { path: Path }): void;
路径渲染事件
参数
参数 | 类型 | 说明 | 默认值 |
---|---|---|---|
path | Path | 渲染的路径实例 | - |
add-path
typescript
(event: "add-path", args: { paths: PathData2 }): void;
添加路径事件
参数
参数 | 类型 | 说明 | 默认值 |
---|---|---|---|
paths | PathData2 | 添加的路径数据 | - |