uni-app 安卓Nvue高德地图设置转向角时逆时针旋转 文档说明rotate为顺时针旋转角度
uni-app 安卓Nvue高德地图设置转向角时逆时针旋转 文档说明rotate为顺时针旋转角度
| 开发环境 | 版本号 | 项目创建方式 |
|---|---|---|
| Windows | Windows10 | HBuilderX |
产品分类:uniapp/App
PC开发环境操作系统:Windows
HBuilderX类型:正式
HBuilderX版本号:3.2.3
手机系统:Android
手机系统版本号:Android 11
手机厂商:华为
手机机型:华为9X
页面类型:vue
打包方式:云端
项目创建方式:HBuilderX
### 示例代码:
```this.covers = [{
id: 1,
width: 47,
height: 72,
rotate: 360-Number(this.coordinate[0].dir),
latitude: this.coordinate[0].latitude,
longitude: this.coordinate[0].longitude,
iconPath: '/static/imgs/track_car.png'
},
{id: 2,
width: 48,
height: 48,
latitude: this.coordinate[0].latitude,
longitude: this.coordinate[0].longitude,
iconPath: '/static/imgs/start.png'
},
{id: 3,
width: 48,
height: 48,
latitude: this.coordinate[this.coordinate.length - 1].latitude,
longitude: this.coordinate[this.coordinate.length - 1].longitude,
iconPath: '/static/imgs/end.png'
}
]```
### bug描述:
后端给的是顺时针角度,安卓nvue上设置rotate之后,markers旋转角逆时针旋转了,小程序上没问题,就APP端用360度减,但是在走translateMarker 方法的时候 直接设置rotate 又回到了顺时针旋转正常,这样会导致轨迹点回放的时候,到第二个点上markers会转一圈再走轨迹,这个问题希望官方大大解答下
更多关于uni-app 安卓Nvue高德地图设置转向角时逆时针旋转 文档说明rotate为顺时针旋转角度的实战教程也可以访问 https://www.itying.com/category-93-b0.html
5 回复
问题已确认
更多关于uni-app 安卓Nvue高德地图设置转向角时逆时针旋转 文档说明rotate为顺时针旋转角度的实战教程也可以访问 https://www.itying.com/category-93-b0.html
感谢回复 官方大大,希望早些修复 抱拳
收到
根据你的描述,这是一个在Android Nvue平台上高德地图组件中rotate参数行为不一致的问题。
问题分析:
- 文档说明
rotate是顺时针旋转角度,但实际在Android Nvue上却表现为逆时针旋转。 - 你在代码中使用
360-Number(this.coordinate[0].dir)进行补偿,这确实能解决静态标记的显示问题。 - 但在使用
translateMarker动画时,直接设置rotate又恢复了文档描述的顺时针行为,导致动画过程中方向突变。
根本原因: 这很可能是Nvue的Android端高德地图原生模块在处理静态标记旋转和动画旋转时存在内部逻辑不一致。静态标记的旋转可能错误地应用了坐标系转换(例如将角度处理为数学极坐标角度,与地图屏幕坐标系的Y轴方向相反)。
临时解决方案:
在调用translateMarker时,需要对旋转角度进行条件处理。建议封装一个角度转换函数:
function getAdjustedRotation(angle, isAnimation = false) {
// 在Android Nvue上,静态标记需要反向,动画时不需要
#ifdef APP-NVUE
#ifdef ANDROID
return isAnimation ? angle : 360 - angle;
#else
return angle;
#endif
#else
return angle;
#endif
}
然后在代码中:
// 静态标记
rotate: getAdjustedRotation(Number(this.coordinate[0].dir), false)
// translateMarker动画
rotate: getAdjustedRotation(newAngle, true)


