Commit 9df807eb authored by xxx's avatar xxx

修改

parent b3fe62e5
...@@ -134,6 +134,11 @@ export default { ...@@ -134,6 +134,11 @@ export default {
batteryEnegy:0, batteryEnegy:0,
//判断卸车1 //判断卸车1
boo1:false, boo1:false,
//暂存的经纬度
oldxy:{
lat:0,//纬度
lng:0,//经度
},
} }
}, },
mounted(){ mounted(){
...@@ -147,7 +152,7 @@ export default { ...@@ -147,7 +152,7 @@ export default {
if(this.carclass == '铲车'){ if(this.carclass == '铲车'){
this.loadData1(); this.loadData1();
} }
//获取报警记录 //获取报警记录以及坐标计算距离并返回给后台
httpGet(vehicleInformationQuery,{number:this.carnumber}).then((res) => { httpGet(vehicleInformationQuery,{number:this.carnumber}).then((res) => {
if(res.code == 200){ if(res.code == 200){
if(res.data.totalElements == 0){ if(res.data.totalElements == 0){
...@@ -174,10 +179,27 @@ export default { ...@@ -174,10 +179,27 @@ export default {
}); });
} }
}); });
//获取车辆坐标计算距离并返回给后台
httpGet(carRealTimeLocationQuery2,{name:res.data.content[0].equipmentName}).then((res2) => {
if(res2.data){
if(this.oldxy.lat == 0 || this.oldxy.lng == 0){
this.oldxy.lat = res2.data.location.y;
this.oldxy.lng = res2.data.location.x;
}else{
let distance1 = this.getDistance(this.oldxy.lat,this.oldxy.lng,res2.data.location.y,res2.data.location.x) + parseFloat(res.data.content[0].odo);
putForJson(vehicleInformationUpdate,{id:res.data.content[0].id,odo:distance1}).then((res) => {});
this.$nextTick(()=>{
this.oldxy.lat = res2.data.location.y;
this.oldxy.lng = res2.data.location.x;
})
}
}
});
} }
} }
}); });
}, 20000)
}, 15000)
}, },
methods:{ methods:{
...@@ -506,6 +528,17 @@ export default { ...@@ -506,6 +528,17 @@ export default {
} }
}); });
}, },
//根据两个经纬度计算距离
getDistance(lat1, lng1, lat2, lng2) {
var radLat1 = lat1 * Math.PI / 180.0;
var radLat2 = lat2 * Math.PI / 180.0;
var a = radLat1 - radLat2;
var b = lng1 * Math.PI / 180.0 - lng2 * Math.PI / 180.0;
var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
s = s * 6378.137 // EARTH_RADIUS;
s = Math.round(s * 10000) / 10000;
return s
},
//执行路径 //执行路径
zhixinglujing(boo){ zhixinglujing(boo){
//this.$refs.mars3dViewerMapMethod.addArrowGraphic3(boo); //this.$refs.mars3dViewerMapMethod.addArrowGraphic3(boo);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment