diff --git a/src/api/factorResources/index.js b/src/api/factorResources/index.js index bbd64ae..d26b323 100644 --- a/src/api/factorResources/index.js +++ b/src/api/factorResources/index.js @@ -38,4 +38,12 @@ export function car_point(params) { method:'get', params }) +} +// 车辆轨迹 +export function car_line(params) { + return request({ + url:'/SafeCompanyVehicleTrack/getById', + method:'get', + params + }) } \ No newline at end of file diff --git a/src/assets/safetyIndex/主屏板块1.png b/src/assets/safetyIndex/modelback.png similarity index 100% rename from src/assets/safetyIndex/主屏板块1.png rename to src/assets/safetyIndex/modelback.png diff --git a/src/views/companyCanban/daolu.vue b/src/views/companyCanban/daolu.vue index f4c0508..63220bd 100644 --- a/src/views/companyCanban/daolu.vue +++ b/src/views/companyCanban/daolu.vue @@ -360,7 +360,7 @@ export default { height: 34%; width: 100%; margin-bottom: 20px; - background: url('~@/assets/safetyIndex/主屏板块1.png') no-repeat; + background: url('~@/assets/safetyIndex/modelback.png') no-repeat; background-size: 100% 100%; .title { diff --git a/src/views/companyCanban/fanggopngji.vue b/src/views/companyCanban/fanggopngji.vue index b7593d1..e3df55c 100644 --- a/src/views/companyCanban/fanggopngji.vue +++ b/src/views/companyCanban/fanggopngji.vue @@ -307,7 +307,7 @@ export default { height: 28.06%; width: 100%; margin-bottom: 20px; - background: url('~@/assets/safetyIndex/主屏板块1.png') no-repeat; + background: url('~@/assets/safetyIndex/modelback.png') no-repeat; background-size: 100% 100%; .title { diff --git a/src/views/companyCanban/fangyi.vue b/src/views/companyCanban/fangyi.vue index 704f498..db33368 100644 --- a/src/views/companyCanban/fangyi.vue +++ b/src/views/companyCanban/fangyi.vue @@ -369,7 +369,7 @@ export default { height: 36.42%; width: 100%; margin-bottom: 20px; - background: url('~@/assets/safetyIndex/主屏板块1.png') no-repeat; + background: url('~@/assets/safetyIndex/modelback.png') no-repeat; background-size: 100% 100%; .title { diff --git a/src/views/companyCanban/lieguan.vue b/src/views/companyCanban/lieguan.vue index c0cedac..220461a 100644 --- a/src/views/companyCanban/lieguan.vue +++ b/src/views/companyCanban/lieguan.vue @@ -454,7 +454,7 @@ export default { .xfwp { width: calc(33.33% - 13.33px); height: 100%; - background: url('~@/assets/safetyIndex/主屏板块1.png') no-repeat; + background: url('~@/assets/safetyIndex/modelback.png') no-repeat; background-size: 100% 100%; display: flex; flex-wrap: wrap; diff --git a/src/views/companyCanban/renyuan.vue b/src/views/companyCanban/renyuan.vue index 74ccec2..c914821 100644 --- a/src/views/companyCanban/renyuan.vue +++ b/src/views/companyCanban/renyuan.vue @@ -263,7 +263,7 @@ export default { height: 25.64%; width: 100%; margin-bottom: 20px; - background: url('~@/assets/safetyIndex/主屏板块1.png') no-repeat; + background: url('~@/assets/safetyIndex/modelback.png') no-repeat; background-size: 100% 100%; .title { diff --git a/src/views/companyCanban/wangluo.vue b/src/views/companyCanban/wangluo.vue index 4e9ee44..0a202ff 100644 --- a/src/views/companyCanban/wangluo.vue +++ b/src/views/companyCanban/wangluo.vue @@ -243,7 +243,7 @@ export default { height: calc(37.94% - 40px); width: 100%; margin-bottom: 20px; - background: url('~@/assets/safetyIndex/主屏板块1.png') no-repeat; + background: url('~@/assets/safetyIndex/modelback.png') no-repeat; background-size: 100% 100%; .title { diff --git a/src/views/companyCanban/weihuapin.vue b/src/views/companyCanban/weihuapin.vue index 8d9519a..04ed9be 100644 --- a/src/views/companyCanban/weihuapin.vue +++ b/src/views/companyCanban/weihuapin.vue @@ -274,7 +274,7 @@ export default { height: calc(37.94% - 40px); width: 100%; margin-bottom: 20px; - background: url('~@/assets/safetyIndex/主屏板块1.png') no-repeat; + background: url('~@/assets/safetyIndex/modelback.png') no-repeat; background-size: 100% 100%; .title { diff --git a/src/views/companyCanban/xiaofang.vue b/src/views/companyCanban/xiaofang.vue index bcc699d..b9e8d57 100644 --- a/src/views/companyCanban/xiaofang.vue +++ b/src/views/companyCanban/xiaofang.vue @@ -219,7 +219,7 @@ export default { .xfwp { width: calc(33.33% - 13.33px); height: 100%; - background: url('~@/assets/safetyIndex/主屏板块1.png') no-repeat; + background: url('~@/assets/safetyIndex/modelback.png') no-repeat; background-size: 100% 100%; display: flex; flex-wrap: wrap; diff --git a/src/views/companyCanban/zhian.vue b/src/views/companyCanban/zhian.vue index 6f1c58a..4c40e18 100644 --- a/src/views/companyCanban/zhian.vue +++ b/src/views/companyCanban/zhian.vue @@ -153,7 +153,7 @@ export default { .xfwp { width: calc(33.33% - 13.33px); height: 100%; - background: url('~@/assets/safetyIndex/主屏板块1.png') no-repeat; + background: url('~@/assets/safetyIndex/modelback.png') no-repeat; background-size: 100% 100%; display: flex; flex-wrap: wrap; diff --git a/src/views/factor/components/factorMap.vue b/src/views/factor/components/factorMap.vue index 355f024..c9a15d4 100644 --- a/src/views/factor/components/factorMap.vue +++ b/src/views/factor/components/factorMap.vue @@ -96,11 +96,11 @@ export default { ); var car_marker = new BMap.Marker(car_point, { icon: car_icon }); // 创建点位 map.addOverlay(car_marker); - car_marker.addEventListener("click",function() { + car_marker.addEventListener("click", function () { // 查看车辆轨迹 // 查看轨迹的点击事件是要重新创建地图的,以该车坐标为中心 - that.$emit('get_car_text',item) - }) + that.$emit("get_car_text", item); + }); }); }, 500); map.centerAndZoom( @@ -198,7 +198,7 @@ export default { } }, // 根据车辆点位重新创建地图 - cause_car_line_map(item) { + cause_car_line_map(item, new_line) { let BMap = window.BMap; let map = new BMap.Map("container", { style: { @@ -208,24 +208,36 @@ export default { //let that = this; // 不改指向后面很多函数无法执行 //let label = new BMap.Label(); setTimeout(() => { - var point = new BMap.Point(item.longitude, item.latitude) + var point = new BMap.Point(item.longitude, item.latitude); // 自定义图标; - var myIcon = {}; - myIcon = new BMap.Icon( - require("@/assets/factor/factor03.png"), - new BMap.Size(20, 40), - { - imageOffset: new BMap.Size(0, 0, 5), // 设置图片偏移 - } + var myIcon = {}; + myIcon = new BMap.Icon( + require("@/assets/factor/factor03.png"), + new BMap.Size(20, 40), + { + imageOffset: new BMap.Size(0, 0, 5), // 设置图片偏移 + } + ); + var marker = new BMap.Marker(point, { icon: myIcon }); // 创建点位 + map.addOverlay(marker); + // 车辆轨迹绘画 + let line_point = []; + for (let i = 0; i < new_line.length; i++) { + line_point.push( + new BMap.Point(new_line[i].longitude, new_line[i].latitude) ); - var marker = new BMap.Marker(point, { icon: myIcon }); // 创建点位 - map.addOverlay(marker); - },500) + } + console.log("line_point", line_point); + let pl = new BMap.Polyline(line_point, { + strokeColor: "blue", + strokeWeight: 6, + strokeOpacity: 0.5, + }); + console.log("pl", pl); + map.addOverlay(pl); + }, 500); - map.centerAndZoom( - new BMap.Point(item.longitude, item.latitude), - 16 - ); // 创建点坐标 + map.centerAndZoom(new BMap.Point(item.longitude, item.latitude), 16); // 创建点坐标 map.setMinZoom(12); // 初始化地图,设置中心点坐标和地图级别 map.setMaxZoom(19); map.enableScrollWheelZoom(true); diff --git a/src/views/factor/index.vue b/src/views/factor/index.vue index 27f87e6..2e6ba95 100644 --- a/src/views/factor/index.vue +++ b/src/views/factor/index.vue @@ -158,6 +158,7 @@ import { queryCompany, queryVideo, car_point, + car_line, } from "@/api/factorResources"; export default { name: "factor", @@ -168,7 +169,7 @@ export default { return { company_list: [], // 七个区域所有的企业 video_list: [], // 七个区域所有监控单位 - car_list:[], // 车辆点位 + car_list: [], // 车辆点位 search: { word: "", select: "企业", @@ -179,7 +180,7 @@ export default { ], btn_video: "", // 复选框文字 btn_item: "", // 复选框文字 - btn_car:'', // 危化品车辆文字 + btn_car: "", // 危化品车辆文字 company_flag: "0", // 公司详情框展示 /////////// 以下范围公司详情框所需对应变量声明 text_company: "", @@ -251,25 +252,25 @@ export default { queryVideo(param).then((res) => { this.video_list = res.data; this.company_list = []; - this.car_list = [] + this.car_list = []; // 重新在地图打点 this.$refs.factorMap.init_map(); }); }, // 展示危化品车辆点位 async get_car() { - this.company_flag = '0' + this.company_flag = "0"; let res = await car_point(); console.log("resss", res); - if(res.code == 200) { - this.car_list = res.data + if (res.code == 200) { + this.car_list = res.data; this.company_list = []; - this.video_list = [] - // 重新在地图打点 + this.video_list = []; + // 重新在地图打点 this.$refs.factorMap.init_map(); // this.btn_car = `危化品车辆(${res.data.length})`; } else if (res.code == 500) { - this.$message.warning(res.msg) + this.$message.warning(res.msg); } }, // 查询企业 @@ -323,20 +324,35 @@ export default { } }, // 查看危化品车辆轨迹 - get_car_text(item) { - // 查看轨迹的点击事件是要重新创建地图的,以该车坐标为中心 - console.log('item',item); - this.$refs.factorMap.cause_car_line_map(item) + async get_car_text(item) { + let params = { + vehicleNo: item.vehicleNo, + }; + let res = await car_line(params); + if (res.code == 200) { + console.log("res", res); + let arr = [ + { longitude: 121.597849, latitude: 29.904037 }, + { longitude: 121.597864, latitude: 29.904234 }, + ]; + const new_line = arr.map((item) => ({ + longitude: item.longitude, + latitude: item.latitude, + })); + this.$message.success("车辆轨迹查询中..."); + // 查看轨迹的点击事件是要重新创建地图的,以该车坐标为中心 + this.$refs.factorMap.cause_car_line_map(item, new_line); + } }, async get_car_point() { let res = await car_point(); console.log("resss", res); - if(res.code == 200) { + if (res.code == 200) { // this.car_list = res.data this.btn_car = `危化品车辆(${res.data.length})`; } else if (res.code == 500) { - this.$message.warning(res.msg) + this.$message.warning(res.msg); } }, // 点击跳转企业档案详情页面 diff --git a/src/views/safetyIndex/anjian.vue b/src/views/safetyIndex/anjian.vue index c3705a8..9e2ad39 100644 --- a/src/views/safetyIndex/anjian.vue +++ b/src/views/safetyIndex/anjian.vue @@ -193,7 +193,7 @@ export default { height: 23%; width: 100%; margin-bottom: 20px; - background: url("~@/assets/safetyIndex/主屏板块1.png") no-repeat; + background: url("~@/assets/safetyIndex/modelback.png") no-repeat; background-size: 100% 100%; .title { diff --git a/src/views/safetyIndex/cheliang.vue b/src/views/safetyIndex/cheliang.vue index e93c848..1a35a01 100644 --- a/src/views/safetyIndex/cheliang.vue +++ b/src/views/safetyIndex/cheliang.vue @@ -335,7 +335,7 @@ export default { height: 23%; width: 100%; margin-bottom: 20px; - background: url("~@/assets/safetyIndex/主屏板块1.png") no-repeat; + background: url("~@/assets/safetyIndex/modelback.png") no-repeat; background-size: 100% 100%; .title { diff --git a/src/views/safetyIndex/index.vue b/src/views/safetyIndex/index.vue index dca3cad..2dc9c71 100644 --- a/src/views/safetyIndex/index.vue +++ b/src/views/safetyIndex/index.vue @@ -73,7 +73,7 @@ export default { height: 22.9%; width: 100%; margin-bottom: 20px; - background: url('~@/assets/safetyIndex/主屏板块1.png') no-repeat; + background: url('~@/assets/safetyIndex/modelback.png') no-repeat; background-size: 100% 100%; } @@ -81,7 +81,7 @@ export default { height: 37.56%; width: 100%; margin-bottom: 20px; - background: url('~@/assets/safetyIndex/主屏板块1.png') no-repeat; + background: url('~@/assets/safetyIndex/modelback.png') no-repeat; background-size: 100% 100%; } } diff --git a/src/views/safetyIndex/shuju.vue b/src/views/safetyIndex/shuju.vue index c101ffa..8749c40 100644 --- a/src/views/safetyIndex/shuju.vue +++ b/src/views/safetyIndex/shuju.vue @@ -133,7 +133,7 @@ export default { height: 37.7%; width: 100%; margin-bottom: 20px; - background: url('~@/assets/safetyIndex/主屏板块1.png') no-repeat; + background: url('~@/assets/safetyIndex/modelback.png') no-repeat; background-size: 100% 100%; diff --git a/src/views/safetyIndex/wupin.vue b/src/views/safetyIndex/wupin.vue index 56f6343..a9c5022 100644 --- a/src/views/safetyIndex/wupin.vue +++ b/src/views/safetyIndex/wupin.vue @@ -219,7 +219,7 @@ export default { height: 37.7%; width: 100%; margin-bottom: 20px; - background: url('~@/assets/safetyIndex/主屏板块1.png') no-repeat; + background: url('~@/assets/safetyIndex/modelback.png') no-repeat; background-size: 100% 100%; diff --git a/src/views/safetyIndex/yuangong.vue b/src/views/safetyIndex/yuangong.vue index d85a112..69f0f63 100644 --- a/src/views/safetyIndex/yuangong.vue +++ b/src/views/safetyIndex/yuangong.vue @@ -511,7 +511,7 @@ export default { height: 35.84%; width: 100%; margin-bottom: 20px; - background: url("~@/assets/safetyIndex/主屏板块1.png") no-repeat; + background: url("~@/assets/safetyIndex/modelback.png") no-repeat; background-size: 100% 100%; .title { diff --git a/src/views/safetyIndex/yujing.vue b/src/views/safetyIndex/yujing.vue index 16b6559..09c021f 100644 --- a/src/views/safetyIndex/yujing.vue +++ b/src/views/safetyIndex/yujing.vue @@ -87,7 +87,7 @@ export default { height: 35.84%; width: 100%; margin-bottom: 20px; - background: url('~@/assets/safetyIndex/主屏板块1.png') no-repeat; + background: url('~@/assets/safetyIndex/modelback.png') no-repeat; background-size: 100% 100%; .title {