master
tangwenkang 2023-12-04 21:55:53 +08:00
parent 64722e587b
commit eb3a7babbb
3 changed files with 71 additions and 41 deletions

View File

@ -83,3 +83,11 @@ export function listRealTime(vin) {
data:vin data:vin
}) })
} }
export function removeRealTime(vinId) {
return request({
url: '/history/car/removeRealTime?vin='+vinId,
method: 'post',
data:vinId
})
}

View File

@ -193,7 +193,18 @@
<script> <script>
import AMapLoader from '@amap/amap-jsapi-loader'; import AMapLoader from '@amap/amap-jsapi-loader';
import {delCar, getCarList, insertCar, listCarType, listFence, listRealTime, realTime, updateCar} from "@/api/table"; import {
delCar,
getCarList,
insertCar,
listCarType,
listFence,
listRealTime,
realTime,
removeRealTime,
updateCar
} from "@/api/table";
export default { export default {
name: 'AMapAnimation', name: 'AMapAnimation',
props: { props: {
@ -247,7 +258,6 @@ export default {
lineArr: [], lineArr: [],
vin:null, vin:null,
carMsg:[], carMsg:[],
vehicle:null
}; };
}, },
mounted() { mounted() {
@ -257,15 +267,8 @@ export default {
this.getList() this.getList()
this.listCarType() this.listCarType()
this.listFence() this.listFence()
this.vehicle = setInterval(this.listRealTime,1000)
}, },
methods: { methods: {
//
listRealTime(){
listRealTime(this.vin).then(res=>{
this.carMsg.push(res.data)
})
},
/*重置表单*/ /*重置表单*/
resetForm() { resetForm() {
this.form = { // form this.form = { // form
@ -279,8 +282,11 @@ export default {
this.$refs.myForm.resetFields(); // this.$refs.myForm.resetFields(); //
}, },
isShowAll(){ isShowAll(){
removeRealTime().then(res=>{ removeRealTime(this.vinId).then(res=>{
if(res.code !== 200){
this.$message.error("删除实时轨迹事件!")
return
}
}) })
this.isShow = true this.isShow = true
this.isList = false this.isList = false
@ -312,12 +318,30 @@ export default {
realTimeTrajectory(carVin){ realTimeTrajectory(carVin){
this.vinId = carVin this.vinId = carVin
this.vin = carVin this.vin = carVin
realTime(this.vin).then(res=>{ realTime(this.vin).then(res=>{
if(res.code !== 200){ if(res.code !== 200){
this.$message.error("获取实时轨迹失败!") this.$message.error("注册实际轨迹事件失败!")
return return
} }
}) })
const updateRealTimeData = () => {
listRealTime(this.vin).then(res => {
const longitude = parseFloat(res.data.longitude.replace(/"/g, ""));
const latitude = parseFloat(res.data.latitude.replace(/"/g, ""));
this.lineArr = [longitude, latitude];
this.carMsg.push(res.data);
});
};
//
setTimeout(() => {
//
updateRealTimeData();
// 1
setInterval(updateRealTimeData, 1000);
}, 3000);
this.isShow = false this.isShow = false
this.isList = true this.isList = true
this.initMap() this.initMap()
@ -434,17 +458,15 @@ export default {
}) })
}, },
startAnimation () { startAnimation () {
setTimeout(()=>{ AMap.plugin('AMap.MoveAnimation', () => {
AMap.plugin('AMap.MoveAnimation', () => { console.log('开始回放')
console.log('开始回放') this.marker.moveAlong(this.lineArr, {
this.marker.moveAlong(this.lineArr, { //
// duration: this.duration,//
duration: this.duration,// // JSAPI2.0 moveAlong
// JSAPI2.0 moveAlong autoRotation: true,
autoRotation: true, });
}); })
})
},2000)
}, },
} }
} }

View File

@ -67,7 +67,7 @@ export default {
parseFloat(obj.longitude.replace(/"/g, "")), parseFloat(obj.longitude.replace(/"/g, "")),
parseFloat(obj.latitude.replace(/"/g, "")) parseFloat(obj.latitude.replace(/"/g, ""))
]); ]);
this.lineArr = [coordinates] this.lineArr = coordinates
console.log(this.lineArr) console.log(this.lineArr)
}) })
}, },
@ -134,23 +134,23 @@ export default {
}) })
}, },
startAnimation () { startAnimation () {
// setTimeout(()=>{ setTimeout(()=>{
// AMap.plugin('AMap.MoveAnimation', () => { AMap.plugin('AMap.MoveAnimation', () => {
// console.log('') console.log('开始回放')
// this.marker.moveAlong(this.lineArr, { this.marker.moveAlong(this.lineArr, {
// // //
// duration: this.duration,// duration: this.duration,//
// // JSAPI2.0 moveAlong // JSAPI2.0 moveAlong
// autoRotation: true, autoRotation: true,
// }); });
// }) })
// },2000) },2000)
this.marker.moveAlong(this.lineArr, { // this.marker.moveAlong(this.lineArr, {
// // //
duration: 200,// // duration: 200,//
// JSAPI2.0 moveAlong // // JSAPI2.0 moveAlong
autoRotation: true, // autoRotation: true,
}); // });
}, },
}, },