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) {
this.$router.push({path: '/client/sever/fence',query:{carId:carId}})
},
realTime(vim) {
this.$router.push({path: '/client/sever/random',query:{vim:vim}})
realTime(vin) {
this.$router.push({path: '/client/sever/random',query:{vin:vin}})
},
/** 查询车辆信息列表 */

View File

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

View File

@ -3,9 +3,8 @@
<el-button type="primary" @click="drawRectangle"></el-button>
<el-button type="primary" @click="editRectangle"></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="container"></div>-->
</div>
</template>
@ -27,7 +26,6 @@ export default {
polygonItem: [], //
polyEditors: [], //
pences:{
groupsId: this.$route.query.groupsId,
list: []
} //
}
@ -39,15 +37,7 @@ export default {
// ",
methods: {
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;
console.log(this.groupsId)
console.log(this.groupsId)
console.log(this.$route)
getSel(this.pences).then(res => {
console.log(res.data)
})

View File

@ -1,6 +1,10 @@
<template>
<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="时间">{{VehicleInfo.time}}</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>
{{vim}}
</div>
</template>
<script>
import { read, open, close } from "@/api/goods/car";
// jsjsjson,
// import from ',
export default {
// import使"
components: {},
props: {},
props: {
paths: {}, //
},
data() {
// "
return {
map: null, //
path: [], //
VehicleInfo: {
// vin
vin: '',
@ -164,7 +172,13 @@ export default {
//
checkDigit: '',
},
vim: this.$route.query.vim
vin: this.$route.query.vin,
carMarker: null, //
carPath: null, //
carPosition: { //
longitude: 116.663817, //
latitude: 39.53177, //
},
}
},
// data",
@ -173,6 +187,47 @@ export default {
watch: {},
// ",
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().then(res =>{
console.log(res)
@ -190,6 +245,14 @@ export default {
},
// - 访DOM",
mounted() {
this.initMap(); //
this.createCar(); //
this.startSimulation(); //
this.intAmap(() => {
if (this.paths) {
this.editRectangle(this.paths);
}
})
},
beforeCreate() {
}, // - ",
@ -200,6 +263,17 @@ export default {
updated() {
}, // - ",
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) {
close().then(res => {
console.log(res)
@ -213,6 +287,10 @@ export default {
} // keep-alive",
}
</script>
<style scoped>
<style lang="scss" scoped>
#amapContainer {
height: 400px;
width: 1200px;
}
</style>

View File

@ -1,116 +1,113 @@
<!--<template>-->
<!-- <div class="container">-->
<!-- <div class="title">实时轨迹</div>-->
<!-- {{vin}}-->
<!-- <div id="map" style="width: 100%; height: 500px;"></div>-->
<!-- <br>-->
<!-- <br>-->
<!-- <div class="title">单体电池最低电压</div>-->
<!-- <div class="value">{{ data.lowestVoltage }}</div>-->
<!-- </div>-->
<!--</template>-->
<template>
<div id="map" style="width: 100%; height: 400px;"></div>
<!-- 地图容器设置了宽度和高度 -->
</template>
<!--<script>-->
<!--import { redisList } from "@/api/fence/fence";-->
<script>
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 {-->
<!-- data() {-->
<!-- return {-->
<!-- map: null,-->
<!-- polyline: null,-->
<!-- 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.carMarker = new AMap.Marker({
map: this.map, //
position: [this.carPosition.longitude, this.carPosition.latitude], //
icon: icon, // 使
offset: new AMap.Pixel(-26, -13), //
});
<!-- this.polyline = new AMap.Polyline({-->
<!-- map: this.map,-->
<!-- path: [],-->
<!-- strokeColor: "#FF0000",-->
<!-- strokeWeight: 5,-->
<!-- });-->
// 线
this.polyline = new AMap.Polyline({
path: this.path,
isOutline: true,
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),-->
<!-- image: 'https://webapi.amap.com/images/car.png',-->
<!-- imageSize: new AMap.Size(30, 15)-->
<!-- });-->
// 线
if (!this.polyline.getMap()) {
this.polyline.setMap(this.map);
}
// 线
this.polyline.setPath(this.path);
<!-- this.carMarker = new AMap.Marker({-->
<!-- icon: carIcon,-->
<!-- offset: new AMap.Pixel(-20, -25),-->
<!-- autoRotation: true,-->
<!-- });-->
<!-- this.carMarker.setMap(this.map);-->
<!-- },-->
<!-- updateTrajectory() {-->
<!-- if (this.data.latitude && this.data.longitude) {-->
<!-- const newPoint = [this.data.longitude, this.data.latitude];-->
<!-- const path = this.polyline.getPath();-->
<!-- path.push(newPoint);-->
<!-- this.polyline.setPath(path);-->
<!-- this.map.setCenter(newPoint);-->
<!-- // -->
<!-- if (this.lastPosition) {-->
<!-- const angle = this.calculateAngle(this.lastPosition)-->
<!-- 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>-->
},
},
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.polyline) {
this.polyline.setMap(null); // 线
}
},
};
</script>