fase()实时轨迹

car_1
王熙朝 2024-06-19 22:30:54 +08:00
parent dbf878c819
commit 87e9200466
5 changed files with 217 additions and 133 deletions

View File

@ -288,8 +288,8 @@ export default {
fence(carId) { fence(carId) {
this.$router.push({path: '/client/sever/fence',query:{carId:carId}}) this.$router.push({path: '/client/sever/fence',query:{carId:carId}})
}, },
realTime(vim) { realTime(vin) {
this.$router.push({path: '/client/sever/random',query:{vim:vim}}) this.$router.push({path: '/client/sever/random',query:{vin:vin}})
}, },
/** 查询车辆信息列表 */ /** 查询车辆信息列表 */

View File

@ -1,7 +1,6 @@
<template> <template>
<div> <div>
{{fenceGroups.groupsName}}下属围栏 <el-button type="text" @click="addGroups(dialogFormVisible = true)">增加围栏组</el-button>
<el-button type="text" @click="add(fenceGroups.groupsId)"></el-button>
<el-table :data="fenceGroups.fenceList"> <el-table :data="fenceGroups.fenceList">
<el-table-column prop="fenceName" label="围栏名称"></el-table-column> <el-table-column prop="fenceName" label="围栏名称"></el-table-column>
<el-table-column prop="fenceType" label="围栏类型"></el-table-column> <el-table-column prop="fenceType" label="围栏类型"></el-table-column>
@ -31,6 +30,18 @@
</span> </span>
</el-table-column> </el-table-column>
</el-table> </el-table>
<el-dialog title="新增围栏组" :visible.sync="dialogFormVisible">
<el-form :model="groups">
<el-form-item label="围栏名称" :label-width="formLabelWidth">
<el-input v-model="groups.groupsName" autocomplete="off"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false"> </el-button>
<el-button type="primary" @click="dialogFormVisible = false"> </el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
@ -46,7 +57,13 @@ export default {
// " // "
return { return {
carId: this.$route.query.carId, carId: this.$route.query.carId,
fenceGroups: {} groups: {
carId: this.$route.query.carId,
groupsName: ''
},
fenceGroups: {},
dialogFormVisible: false,
formLabelWidth: '120px'
} }
}, },
// data", // data",
@ -69,9 +86,11 @@ export default {
this.getInfo() this.getInfo()
}) })
}, },
//
addGroups() {},
// //
add(groupsId) { add(groupsId) {
this.$router.push({path:'/client/sever/map',query:{groupsId:groupsId}}) // this.$router.push({path:'/client/sever/map',query:{groupsId:groupsId}})
}, },
// //
query(fenceId) { query(fenceId) {

View File

@ -3,9 +3,8 @@
<el-button type="primary" @click="drawRectangle"></el-button> <el-button type="primary" @click="drawRectangle"></el-button>
<el-button type="primary" @click="editRectangle"></el-button> <el-button type="primary" @click="editRectangle"></el-button>
<el-button type="primary" @click="deleRectangle"></el-button> <el-button type="primary" @click="deleRectangle"></el-button>
<el-button type="primary" @click="sel"></el-button> <el-button type="primary" @click="sel"></el-button>
<div id="amapContainer"></div> <div id="amapContainer"></div>
<!-- <div id="container"></div>-->
</div> </div>
</template> </template>
@ -27,7 +26,6 @@ export default {
polygonItem: [], // polygonItem: [], //
polyEditors: [], // polyEditors: [], //
pences:{ pences:{
groupsId: this.$route.query.groupsId,
list: [] list: []
} // } //
} }
@ -39,15 +37,7 @@ export default {
// ", // ",
methods: { methods: {
sel() {// sel() {//
const jsonData = JSON.stringify(this.polygonItem[0].w.path)
const jsonPare = JSON.parse(jsonData)
jsonPare.forEach(res => {
// console.log(res)
})
this.pences.list = this.polygonItem[0].w.path; this.pences.list = this.polygonItem[0].w.path;
console.log(this.groupsId)
console.log(this.groupsId)
console.log(this.$route)
getSel(this.pences).then(res => { getSel(this.pences).then(res => {
console.log(res.data) console.log(res.data)
}) })

View File

@ -1,6 +1,10 @@
<template> <template>
<div> <div>
<el-descriptions title="垂直带边框列表" direction="vertical" :column="4" :model="VehicleInfo" border> <div class="index">
<div id="map" style="width: 100%; height: 400px;"></div>
</div>
<el-descriptions title="实时数据" direction="vertical" :column="4" :model="VehicleInfo" border>
<el-descriptions-item label="vin">{{VehicleInfo.vin}}</el-descriptions-item> <el-descriptions-item label="vin">{{VehicleInfo.vin}}</el-descriptions-item>
<el-descriptions-item label="时间">{{VehicleInfo.time}}</el-descriptions-item> <el-descriptions-item label="时间">{{VehicleInfo.time}}</el-descriptions-item>
<el-descriptions-item label="经度">{{VehicleInfo.longitude}}</el-descriptions-item> <el-descriptions-item label="经度">{{VehicleInfo.longitude}}</el-descriptions-item>
@ -51,21 +55,25 @@
<!-- <el-descriptions-item label="校验位">{{VehicleInfo.checkDigit}}</el-descriptions-item>--> <!-- <el-descriptions-item label="校验位">{{VehicleInfo.checkDigit}}</el-descriptions-item>-->
</el-descriptions> </el-descriptions>
{{vim}}
</div> </div>
</template> </template>
<script> <script>
import { read, open, close } from "@/api/goods/car"; import { read, open, close } from "@/api/goods/car";
// jsjsjson, // jsjsjson,
// import from ', // import from ',
export default { export default {
// import使" // import使"
components: {}, components: {},
props: {}, props: {
paths: {}, //
},
data() { data() {
// " // "
return { return {
map: null, //
path: [], //
VehicleInfo: { VehicleInfo: {
// vin // vin
vin: '', vin: '',
@ -164,7 +172,13 @@ export default {
// //
checkDigit: '', checkDigit: '',
}, },
vim: this.$route.query.vim vin: this.$route.query.vin,
carMarker: null, //
carPath: null, //
carPosition: { //
longitude: 116.663817, //
latitude: 39.53177, //
},
} }
}, },
// data", // data",
@ -173,6 +187,47 @@ export default {
watch: {}, watch: {},
// ", // ",
methods: { methods: {
//
initMap() {
//
this.map = new AMap.Map('map', {
zoom: 15, //
center: [this.carPosition.longitude, this.carPosition.latitude], //
});
},
createCar() {
//
const icon = new AMap.Icon({
size: new AMap.Size(50, 50), //
image: 'https://s1.4sai.com/src/img/png/37/3760fd545ff848c2b241b7cf400b3dd7.png?imageView2/2/w/256&e=1735488000&token=1srnZGLKZ0Aqlz6dk7yF4SkiYf4eP-YrEOdM1sob:F5xvrYJwsejuj9uCJhs70CQ7-mg=', //
imageSize: new AMap.Size(50, 50), //
});
this.carMarker = new AMap.Marker({
map: this.map, //
position: [this.carPosition.longitude, this.carPosition.latitude], //
icon: icon, // 使
offset: new AMap.Pixel(-26, -13), //
});
},
startSimulation() {
// moveCar
setInterval(() => {
this.moveCar();
}, 1000);
},
moveCar() {
//
const newLng = this.VehicleInfo.longitude; // 0.001
// const newLng = this.carPosition.longitude + 0.001; // 0.001
const newLat = this.VehicleInfo.latitude; // 0.00050.001
// const newLat = this.carPosition.latitude + 0.001 * Math.random() * 0.5; // 0.00050.001
// carPath
// carPath 使 AMap.Polyline API
// this.carPath.push([newLng, newLat]); // carPath Polyline
this.carMarker.setPosition([newLng, newLat]); //
this.carPosition = { longitude: newLng, latitude: newLat }; //
},
open() { open() {
open().then(res =>{ open().then(res =>{
console.log(res) console.log(res)
@ -190,6 +245,14 @@ export default {
}, },
// - 访DOM", // - 访DOM",
mounted() { mounted() {
this.initMap(); //
this.createCar(); //
this.startSimulation(); //
this.intAmap(() => {
if (this.paths) {
this.editRectangle(this.paths);
}
})
}, },
beforeCreate() { beforeCreate() {
}, // - ", }, // - ",
@ -200,6 +263,17 @@ export default {
updated() { updated() {
}, // - ", }, // - ",
beforeDestroy() { beforeDestroy() {
//
if (this.carPath) {
this.carPath.setMap(null); // carPath Polyline
}
if (this.carMarker) {
this.carMarker.setMap(null); //
}
if (this.map) {
this.map.destroy(); //
}
//
if (this.timer) { if (this.timer) {
close().then(res => { close().then(res => {
console.log(res) console.log(res)
@ -213,6 +287,10 @@ export default {
} // keep-alive", } // keep-alive",
} }
</script> </script>
<style scoped> <style lang="scss" scoped>
#amapContainer {
height: 400px;
width: 1200px;
}
</style> </style>

View File

@ -1,116 +1,113 @@
<!--<template>--> <template>
<!-- <div class="container">--> <div id="map" style="width: 100%; height: 400px;"></div>
<!-- <div class="title">实时轨迹</div>--> <!-- 地图容器设置了宽度和高度 -->
<!-- {{vin}}--> </template>
<!-- <div id="map" style="width: 100%; height: 500px;"></div>-->
<!-- <br>-->
<!-- <br>-->
<!-- <div class="title">单体电池最低电压</div>-->
<!-- <div class="value">{{ data.lowestVoltage }}</div>-->
<!-- </div>-->
<!--</template>-->
<!--<script>--> <script>
<!--import { redisList } from "@/api/fence/fence";--> export default {
name: 'GaodeMap', //
data() {
return {
map: null, //
carMarker: null, //
carPath: null, //
carPosition: { //
longitude: 116.397428, //
latitude: 39.90923, //
},
path: []
};
},
mounted() {
this.initMap(); //
this.createCar(); //
this.startSimulation(); //
},
methods: {
initMap() {
//
this.map = new AMap.Map('map', {
zoom: 15, //
center: [this.carPosition.longitude, this.carPosition.latitude], //
});
this.polyline = new AMap.Polyline({
map: this.map,
path: [],
strokeColor: "#FF0000",
strokeWeight: 5,
});
},
createCar() {
//
const icon = new AMap.Icon({
size: new AMap.Size(50, 50), //
image: 'https://s1.4sai.com/src/img/png/37/3760fd545ff848c2b241b7cf400b3dd7.png?imageView2/2/w/256&e=1735488000&token=1srnZGLKZ0Aqlz6dk7yF4SkiYf4eP-YrEOdM1sob:F5xvrYJwsejuj9uCJhs70CQ7-mg=', //
imageSize: new AMap.Size(50, 50), //
});
<!--export default {--> this.carMarker = new AMap.Marker({
<!-- data() {--> map: this.map, //
<!-- return {--> position: [this.carPosition.longitude, this.carPosition.latitude], //
<!-- map: null,--> icon: icon, // 使
<!-- polyline: null,--> offset: new AMap.Pixel(-26, -13), //
<!-- carMarker: null,--> });
<!-- vin: this.$route.params.vin,-->
<!-- intervalId: null,-->
<!-- data: {},-->
<!-- lastPosition: null, // -->
<!-- };-->
<!-- },-->
<!-- created() {-->
<!-- this.intervalId = setInterval(this.fetchData, 1000);-->
<!-- this.fetchData();-->
<!-- },-->
<!-- methods: {-->
<!-- fetchData() {-->
<!-- console.log(this.vin);-->
<!-- redisList(this.vin)-->
<!-- .then(res => {-->
<!-- console.log("res:{}", res);-->
<!-- this.data = res.data;-->
<!-- this.updateTrajectory();-->
<!-- })-->
<!-- .catch(err => {-->
<!-- console.error("Error fetching data:", err);-->
<!-- });-->
<!-- },-->
<!-- initMap() {-->
<!-- this.map = new AMap.Map('map', {-->
<!-- center: [116.397428, 39.90923],-->
<!-- zoom: 13,-->
<!-- });-->
<!-- this.polyline = new AMap.Polyline({--> // 线
<!-- map: this.map,--> this.polyline = new AMap.Polyline({
<!-- path: [],--> path: this.path,
<!-- strokeColor: "#FF0000",--> isOutline: true,
<!-- strokeWeight: 5,--> outlineColor: '#000000',
<!-- });--> borderWeight: 1,
lineJoin: 'round',
lineCap: 'round',
strokeColor: '#0091ff',
strokeWeight: 6,
// Polyline
});
},
startSimulation() {
// moveCar
setInterval(() => {
this.moveCar();
}, 1000);
},
moveCar() {
//
const newLng = this.carPosition.longitude + 0.001; // 0.001
const newLat = this.carPosition.latitude + 0.001 * Math.random() * 0.5; // 0.00050.001
// carPath
// carPath 使 AMap.Polyline API
// this.carPath.push([newLng, newLat]); // carPath Polyline
this.carMarker.setPosition([newLng, newLat]); //
this.carPosition = { longitude: newLng, latitude: newLat }; //
//
this.path.push(this.carPosition);
//
this.carMarker.setPosition(this.carPosition);
<!-- const carIcon = new AMap.Icon({--> // 线
<!-- size: new AMap.Size(40, 50),--> if (!this.polyline.getMap()) {
<!-- image: 'https://webapi.amap.com/images/car.png',--> this.polyline.setMap(this.map);
<!-- imageSize: new AMap.Size(30, 15)--> }
<!-- });--> // 线
this.polyline.setPath(this.path);
<!-- this.carMarker = new AMap.Marker({--> },
<!-- icon: carIcon,--> },
<!-- offset: new AMap.Pixel(-20, -25),--> beforeDestroy() {
<!-- autoRotation: true,--> //
<!-- });--> if (this.carPath) {
this.carPath.setMap(null); // carPath Polyline
<!-- this.carMarker.setMap(this.map);--> }
<!-- },--> if (this.carMarker) {
<!-- updateTrajectory() {--> this.carMarker.setMap(null); //
<!-- if (this.data.latitude && this.data.longitude) {--> }
<!-- const newPoint = [this.data.longitude, this.data.latitude];--> if (this.map) {
<!-- const path = this.polyline.getPath();--> this.map.destroy(); //
<!-- path.push(newPoint);--> }
<!-- this.polyline.setPath(path);--> if (this.polyline) {
<!-- this.map.setCenter(newPoint);--> this.polyline.setMap(null); // 线
}
<!-- // --> },
<!-- if (this.lastPosition) {--> };
<!-- const angle = this.calculateAngle(this.lastPosition)--> </script>
<!-- this.calculateAngle(this.lastPosition, newPoint);-->
<!-- this.carMarker.setAngle(angle);-->
<!-- }-->
<!-- this.carMarker.setPosition(newPoint);-->
<!-- this.lastPosition = newPoint; // -->
<!-- } else {-->
<!-- console.error('Invalid latitude or longitude data:', this.data);-->
<!-- }-->
<!-- },-->
<!-- calculateAngle(start, end) {-->
<!-- const [startLng, startLat] = start;-->
<!-- const [endLng, endLat] = end;-->
<!-- const deltaLng = endLng - startLng;-->
<!-- const deltaLat = endLat - startLat;-->
<!-- const angle = Math.atan2(deltaLat, deltaLng) * (180 / Math.PI);-->
<!-- return angle;-->
<!-- }-->
<!-- },-->
<!-- mounted() {-->
<!-- this.initMap();-->
<!-- },-->
<!-- beforeDestroy() {-->
<!-- if (this.intervalId) {-->
<!-- clearInterval(this.intervalId);-->
<!-- }-->
<!-- if (this.map) {-->
<!-- this.map.destroy();-->
<!-- }-->
<!-- },-->
<!--};-->
<!--</script>-->