animateToNextPoint: function() {
if (!this.data.isPlaying || this.data.currentIndex >= this.data.trackPoints.length - 1) {
this.setData({ isPlaying: false });
return;
}
const currentIndex = this.data.currentIndex;
const nextIndex = currentIndex + 1;
const currentPoint = this.data.trackPoints[currentIndex];
const nextPoint = this.data.trackPoints[nextIndex];
const distance = this.calculateDistance(
currentPoint.latitude, currentPoint.longitude,
nextPoint.latitude, nextPoint.longitude
);
const baseDuration = 1000;
const speedFactor = this.data.speedOptions[this.data.speedIndex];
const duration = Math.max(300, baseDuration / speedFactor);
this.data.mapContext.translateMarker({
markerId: 2,
destination: {
longitude: nextPoint.longitude,
latitude: nextPoint.latitude
},
autoRotate: true,
rotate: 0,
duration: duration,
animationEnd: () => {
const traveledDistance = parseFloat(this.data.traveledDistance) + distance;
const elapsedSeconds = Math.floor((Date.now() - this.data.startTime) / 1000);
const minutes = Math.floor(elapsedSeconds / 60);
const seconds = elapsedSeconds % 60;
const elapsedTime = `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
const progress = ((nextIndex + 1) / this.data.trackPoints.length * 100).toFixed(1);
this.setData({
currentIndex: nextIndex,
longitude: nextPoint.longitude,
latitude: nextPoint.latitude,
currentSpeed: nextPoint.speed,
currentPosition: `经度:${nextPoint.longitude.toFixed(6)}\n纬度:${nextPoint.latitude.toFixed(6)}`,
traveledDistance: traveledDistance.toFixed(2),
elapsedTime,
progress
});
if (nextIndex < this.data.trackPoints.length - 1) {
this.data.animationTimer = setTimeout(() => {
this.animateToNextPoint();
}, 50);
} else {
this.setData({
isPlaying: false,
currentSpeed: 0
});
wx.showToast({
title: '轨迹回放完成',
icon: 'success'
});
}
}
});
},
请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。
鸿蒙next中系统微信小程序使用 MapContext.translateMarker 无效果
不管是ios还是安卓都可以正常使用,只有鸿蒙不能进入MapContext.translateMarker