更新实时轨迹9

master
tangwenkang 2023-12-03 21:22:39 +08:00
parent 1337596819
commit b8ad239363
1 changed files with 6 additions and 16 deletions

View File

@ -20,9 +20,6 @@ export default {
arr:[],
lineArr:null,
carMsg:[],
currentIndex:0 ,//
currentObject: null, //
timer: null //
}
},
mounted() {
@ -51,22 +48,15 @@ export default {
historyMap(this.recordCar).then(res=>{
console.log(res)
this.carMsg = res.data
// res.data.forEach(item=>{
// this.carMsg = item
// this.arr.push(item.longitude.replace(/"/g, "") +","+item.latitude.replace(/"/g, ""))
// this.lineArr = this.arr.map(item => item.trim().replace(/'/g, '').split(','))
// console.log(this.lineArr)
// })
res.data.forEach(item=>{
this.carMsg = item
this.arr.push(item.longitude.replace(/"/g, "") +","+item.latitude.replace(/"/g, ""))
this.lineArr = this.arr.map(item => item.trim().replace(/'/g, '').split(','))
console.log(this.lineArr)
})
})
this.initMap()
this.startAnimation()
this.currentObject = this.carMsg[this.currentIndex]; //
//
this.timer = setInterval(() => {
this.currentIndex = (this.currentIndex + 1) % this.carMsg.length; //
this.currentObject = this.carMsg[this.currentIndex]; //
}, 1000);
},
initMap() {
AMapLoader.load({