4.12更新

master
黄大举 2024-04-12 11:48:48 +08:00
parent 99e4f3e912
commit ff7101d256
2 changed files with 120 additions and 5 deletions

View File

@ -13,7 +13,7 @@ export function listRecords(query) {
export function delRecords(recordsId) { export function delRecords(recordsId) {
return request({ return request({
url: '/business/records/delete/' + recordsId, url: '/business/records/delete/' + recordsId,
method: 'post' method: 'delete'
}) })
} }

View File

@ -5,28 +5,44 @@
<div id="container"></div> <div id="container"></div>
</div> </div>
{{ this.vehicle }}
</div> </div>
</template> </template>
<script> <script>
import AMapLoader from "@amap/amap-jsapi-loader"; import AMapLoader from "@amap/amap-jsapi-loader";
import {getPosition, vehicleData} from "@/api/business/records";
export default { export default {
name: "map-view", name: "map-view",
data() { data() {
return { return {
carPosition: ["116.397428", "39.90923"], // carPosition: ["116.6871620", "39.5228750"], //
carMarker: null, // Marker carMarker: null, // Marker
animationInterval:null// animationInterval: null,//
lineArr: [],
recordsId: 0,
vehicle: {}
}; };
}, },
created() {
this.recordsId = this.$route.query.recordsId;
this.getFindVD()
},
mounted() { mounted() {
this.initAMap(); this.initAMap();
// echarts
this.initBarChart();
}, },
beforeDestroy() { beforeDestroy() {
clearInterval(this.animationInterval);// clearInterval(this.animationInterval);//
this.map?.destroy(); this.map?.destroy();
}, },
methods: { methods: {
getFindVD() {
vehicleData(this.recordsId)
},
initAMap() { initAMap() {
AMapLoader.load({ AMapLoader.load({
key: "ce38a6b072b603934f6270bd9e97ed49", // WebKey load key: "ce38a6b072b603934f6270bd9e97ed49", // WebKey load
@ -40,12 +56,14 @@ export default {
zoom: 11, // zoom: 11, //
center: [116.397428, 39.90923], // center: [116.397428, 39.90923], //
}); });
// //
this.carMarker = new AMap.Marker({ this.carMarker = new AMap.Marker({
position: this.carPosition, position: this.carPosition,
icon: 'https://webapi.amap.com/images/car.png', icon: 'https://webapi.amap.com/images/car.png',
map: this.map, // Marker map: this.map, // Marker
}); });
// //
this.startCarAnimation(); this.startCarAnimation();
}) })
@ -53,13 +71,98 @@ export default {
console.log(e); console.log(e);
}); });
}, },
startCarAnimation() { startCarAnimation() {
this.animationInterval = setInterval(() => { this.animationInterval = setInterval(() => {
this.getRealTimeDataAndUpdatePosition();
}, 1000); }, 1000);
}, },
getRealTimeDataAndUpdatePosition() {
getPosition(this.recordsId)
.then(response => {
this.vehicle = response.data
//
this.carPosition = [this.vehicle.longitude, this.vehicle.latitude];
//Marker
this.carMarker.setPosition(this.carPosition);
// this.center.setPosition(this.carPosition);
})
},
// initBarChart() {
// // $ref
// let myChart = this.$echarts.init(this.$refs.barChart);
// let option = {
// series: [
// {
// type: 'gauge',
// axisLine: {
// lineStyle: {
// width: 30,
// color: [
// [0.3, '#67e0e3'],
// [0.7, '#37a2da'],
// [1, '#fd666d']
// ]
// }
// },
// pointer: {
// itemStyle: {
// color: 'auto'
// }
// },
// axisTick: {
// distance: -30,
// length: 8,
// lineStyle: {
// color: '#fff',
// width: 2
// }
// },
// splitLine: {
// distance: -30,
// length: 30,
// lineStyle: {
// color: '#fff',
// width: 4
// }
// },
// axisLabel: {
// color: 'inherit',
// distance: 40,
// fontSize: 20
// },
// detail: {
// valueAnimation: true,
// formatter: '{value} km/h',
// color: 'inherit'
// },
// data: [
// {
// value: 70
// }
// ]
// }
// ]
// };
// setInterval(function () {
// myChart.setOption({
// series: [
// {
// data: [
// {
// value: +(Math.random() * 100).toFixed(2)
// }
// ]
// }
// ]
// });
// }, 2000);
// myChart.setOption(option);
// },
}, },
}; }
</script> </script>
<style scoped> <style scoped>
#container{ #container{
@ -72,4 +175,16 @@ export default {
border: none !important; /* 移除Marker的边框 */ border: none !important; /* 移除Marker的边框 */
box-shadow: none !important; /* 移除Marker的阴影 */ box-shadow: none !important; /* 移除Marker的阴影 */
} }
.home {
width: 500px;
height: 400px;
margin: auto;
border: 3px solid lightcoral;
// ....
.barChart {
width: 100%;
height: 100%;
}
}
</style> </style>