carline(linedata) {
linedata = [{
latitude: 34.032236,
longitude: 108.720464
},
{
latitude: 34.042236,
longitude: 108.710688
},
{
latitude: 34.052236,
longitude: 108.720688
},
{
latitude: 34.072236,
longitude: 108.720688
}
]
let _this = this
clearInterval(_this.timer);
let cargps = []
linedata.forEach(function(item, index) {
cargps.push({
id: index,
latitude: item.latitude,
longitude: item.longitude,
iconPath: '../../static/iconpj/carbule.png',
width: 20,
height: 20,
})
})
var i = 0;
_this.markers = [cargps[i]]
var mapContext = uni.createMapContext("myMap", this);
let translateMarkerConfig = {
markerId: 0,
destination: {
latitude: cargps[i].latitude,
longitude: cargps[i].longitude,
},
duration: 1000,
animationEnd: function() {
console.log('1轨迹回放完成')
// 轨迹回放完成
},
fail(e) {
// 轨迹回放失败
console.log('轨迹回放失败' + e)
},
}
mapContext.translateMarker(translateMarkerConfig)
console.log(cargps[i])
_this.timer = setInterval(() => {
console.log(cargps[i].latitude)
let timefink = {
markerId: 0,
destination: {
latitude: cargps[i + 1].latitude,
longitude: cargps[i + 1].longitude,
},
duration: 1000,
animationEnd: function() {
console.log('2轨迹回放完成')
// 轨迹回放完成
},
fail(e) {
// 轨迹回放失败
console.log('轨迹回放失败' + e)
},
}
mapContext.translateMarker(timefink)
i++
if (i + 1 == cargps.length) {
i = 0
clearInterval(_this.timer);
}
}, 1000);
},
1***@qq.com (作者)
留个联系方式么?大佬?
2021-06-11 12:40