1.开发环境mpvue
+微信小程序
。
2.markers
里的轨迹通过定时器
绘制时,有闪烁问题。
3.具体代码
<map id="map" :longitude="longitude" :latitude="latitude" :scale="localScale" :polyline="polyline" :markers="localMarker" style="width: 100%; height: 88%;">
let show= () => {
this.playTrajectory=setTimeout(() => {
// console.log(this.polyline[0].points[this.markerIndex].longitude,this.polyline[0].points[this.markerIndex].latitude)
// this.movePoints(this.polyline[0].points[this.markerIndex].longitude,this.polyline[0].points[this.markerIndex].latitude)
this.localMarker[1].latitude= this.polyline[0].points[this.markerIndex].latitude
this.localMarker[1].longitude= this.polyline[0].points[this.markerIndex].longitude
this.markerIndex++;
if(this.markerIndex<this.polyline[0].points.length){
show()
}else{
this.changeIcon=playIcon;
this.markerIndex=0;
this.isPlayNow=false;
}
},200)
}
if(this.isPlayNow){
clearTimeout(this.playTrajectory);
}else{
show();
}
4.尝试过通过官方APImapCtx.translateMarker
去移动坐标点到下一个目的地(上述代码注释部分)。但是没啥卵用,连动也不动了,一直在原地闪烁。
具体代码:
movePoints(lon,lat) {
let mapCtx = wx.createMapContext("map");
mapCtx.translateMarker({
markerId:0,
destination:{longitude:lon,latitude:lat},
autoRotate:true,
rotate:0
})
},
我想请问作者如何实现这种回放功能的?