更新实时轨迹

master
tangwenkang 2023-12-03 14:08:21 +08:00
parent 016bd5d71b
commit f3d20ec9d6
3 changed files with 35 additions and 25 deletions

View File

@ -67,3 +67,19 @@ export function historyMap(recordCar) {
data:recordCar data:recordCar
}) })
} }
export function realTime(vin) {
return request({
url: '/history/car/realTime?vin='+vin,
method: 'post',
data:vin
})
}
export function listRealTime(vin) {
return request({
url: '/history/car/listRealTime?vin='+vin,
method: 'post',
data:vin
})
}

View File

@ -101,7 +101,7 @@
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="primary" @click="updateCarList(scope.row)"></el-button> <el-button type="primary" @click="updateCarList(scope.row)"></el-button>
<el-button type="primary" @click="delCar(scope.row.carVin)"></el-button> <el-button type="primary" @click="delCar(scope.row.carVin)"></el-button>
<el-button type="primary" @click="realTimeTrajectory"></el-button> <el-button type="primary" @click="realTimeTrajectory(scope.row.carVin)"></el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -192,7 +192,7 @@
<script> <script>
import AMapLoader from '@amap/amap-jsapi-loader'; import AMapLoader from '@amap/amap-jsapi-loader';
import {delCar, getCarList, insertCar, listCarType, listFence, updateCar} from "@/api/table"; import {delCar, getCarList, insertCar, listCarType, listFence, listRealTime, realTime, updateCar} from "@/api/table";
export default { export default {
name: 'AMapAnimation', name: 'AMapAnimation',
props: { props: {
@ -242,26 +242,8 @@ export default {
AMap: null, AMap: null,
map: null, map: null,
marker: null, marker: null,
lineArr: [ lineArr: [],
[116.478935,39.997761], vin:null,
[116.478939,39.997825],
[116.478912,39.998549],
[116.478912,39.998549],
[116.478998,39.998555],
[116.478998,39.998555],
[116.479282,39.99856],
[116.479658,39.998528],
[116.480151,39.998453],
[116.480784,39.998302],
[116.480784,39.998302],
[116.481149,39.998184],
[116.481573,39.997997],
[116.481863,39.997846],
[116.482072,39.997718],
[116.482362,39.997718],
[116.483633,39.998935],
[116.48367,39.998968],
[116.484648,39.999861]],
}; };
}, },
mounted() { mounted() {
@ -314,11 +296,24 @@ export default {
}) })
}, },
/*地图展示*/ /*地图展示*/
realTimeTrajectory(){ realTimeTrajectory(carVin){
this.vin = carVin
realTime(this.vin).then(res=>{
if(res.code!== 200){
this.$message.error("获取实时轨迹失败!")
return
}
})
this.isShow = false this.isShow = false
this.isList = true this.isList = true
this.initMap() this.initMap()
this.startAnimation() this.startAnimation()
setInterval(() => {
//
listRealTime(this.vin).then(res=>{
this.lineArr.push(res.longitude.replace(/"/g, "") +","+res.latitude.replace(/"/g, ""))
})
}, 1000); //
}, },
/*刷新*/ /*刷新*/
refreshTable(){ refreshTable(){
@ -335,7 +330,6 @@ export default {
/*车辆列表*/ /*车辆列表*/
getList(){ getList(){
getCarList(this.form).then(response => { getCarList(this.form).then(response => {
console.log(response)
this.carList = response.data.list this.carList = response.data.list
this.total = response.data.total this.total = response.data.total
}) })

View File

@ -71,7 +71,7 @@ export default {
"AMap.DragRoute", "AMap.DragRoute",
"AMap.MoveAnimation"], // 使'AMap.Scale' "AMap.MoveAnimation"], // 使'AMap.Scale'
}).then((AMap) => { }).then((AMap) => {
// DOM // DOM
this.map = new AMap.Map("container", { //id this.map = new AMap.Map("container", { //id
resizeEnable: true, resizeEnable: true,
viewMode: "2D", // 使3D viewMode: "2D", // 使3D