From e436627f31f9462a5c348ac4001a6aab56ed0989 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?home=E5=AD=99?= <1162067978@qq.com> Date: Sun, 29 Jun 2025 15:49:29 +0800 Subject: [PATCH] 1 --- src/assets/js/mapData.js | 2 +- src/views/page/largeScreen.vue | 39 ++++++++++++++++++------------- src/views/page/largeScreen3.vue | 41 ++++++++++++++++++--------------- vue.config.js | 4 ++-- 4 files changed, 48 insertions(+), 38 deletions(-) diff --git a/src/assets/js/mapData.js b/src/assets/js/mapData.js index c39800d2..0f97a56e 100644 --- a/src/assets/js/mapData.js +++ b/src/assets/js/mapData.js @@ -1 +1 @@ -export default {"features":[{"geometry":{"coordinates":[[121.696882,31.411424],[121.696958,31.41096],[121.697851,31.411053],[121.69778,31.411508],[121.696878,31.411428]],"type":"LineString"},"type":"Feature","properties":{}},{"geometry":{"coordinates":[[121.695994,31.411383],[121.696079,31.410871],[121.696878,31.410964],[121.696769,31.411456],[121.695984,31.411379]],"type":"LineString"},"type":"Feature","properties":{}},{"geometry":{"coordinates":[[121.694794,31.411299],[121.69495,31.410742],[121.695937,31.410855],[121.695819,31.411412],[121.694789,31.411295]],"type":"LineString"},"type":"Feature","properties":{}},{"geometry":{"coordinates":[[121.694978,31.41067],[121.695143,31.410234],[121.69606,31.410347],[121.695914,31.410779],[121.694978,31.41067]],"type":"LineString"},"type":"Feature","properties":{}},{"geometry":{"coordinates":[[121.696055,31.410779],[121.696178,31.410359],[121.696816,31.41044],[121.696868,31.410448],[121.696759,31.410875],[121.696055,31.410771]],"type":"LineString"},"type":"Feature","properties":{}},{"geometry":{"coordinates":[[121.698399,31.411109],[121.69847,31.410625],[121.700237,31.410762],[121.700162,31.411258],[121.698404,31.411105]],"type":"LineString"},"type":"Feature","properties":{}},{"geometry":{"coordinates":[[121.698182,31.41042],[121.698229,31.410089],[121.700525,31.410238],[121.700445,31.410605],[121.698168,31.41042]],"type":"LineString"},"type":"Feature","properties":{}},{"geometry":{"coordinates":[[121.698111,31.409996],[121.698139,31.409702],[121.700544,31.409871],[121.700488,31.410149],[121.698106,31.409996]],"type":"LineString"},"type":"Feature","properties":{}},{"geometry":{"coordinates":[[121.698097,31.409557],[121.698125,31.40927],[121.700558,31.40946],[121.700511,31.409742],[121.698101,31.409553]],"type":"LineString"},"type":"Feature","properties":{}},{"geometry":{"coordinates":[[121.69812,31.409186],[121.698149,31.40898],[121.700015,31.409133],[121.699973,31.409327],[121.698111,31.409186]],"type":"LineString"},"type":"Feature","properties":{}}],"type":"FeatureCollection"} +export default {"features":[{"geometry":{"coordinates":[[121.694759,31.411309],[121.694814,31.410775],[121.695937,31.410855],[121.695883,31.411398],[121.694758,31.411311]],"type":"LineString"},"type":"Feature","properties":{}},{"geometry":{"coordinates":[[121.695245,31.409673],[121.695312,31.409294],[121.69597,31.40934],[121.695928,31.409709],[121.695257,31.409663]],"type":"LineString"},"type":"Feature","properties":{}},{"geometry":{"coordinates":[[121.696057,31.409703],[121.696095,31.409358],[121.696776,31.409394],[121.69675,31.409753],[121.696064,31.409704]],"type":"LineString"},"type":"Feature","properties":{}},{"geometry":{"coordinates":[[[121.696013,31.410749],[121.696052,31.41026],[121.696782,31.410319],[121.696747,31.410808],[121.696013,31.410749]]],"type":"Polygon"},"type":"Feature","properties":{}},{"geometry":{"coordinates":[[121.694947,31.410667],[121.694989,31.410171],[121.695972,31.410251],[121.69591,31.410749],[121.694947,31.410673]],"type":"LineString"},"type":"Feature","properties":{}},{"geometry":{"coordinates":[[121.698151,31.408888],[121.698187,31.408636],[121.700038,31.408772],[121.700008,31.409038],[121.698153,31.408888]],"type":"LineString"},"type":"Feature","properties":{}},{"geometry":{"coordinates":[[121.698434,31.410897],[121.698487,31.410465],[121.700263,31.410594],[121.700227,31.411016],[121.698435,31.410893]],"type":"LineString"},"type":"Feature","properties":{}},{"geometry":{"coordinates":[[121.698255,31.410282],[121.698273,31.41009],[121.698288,31.409971],[121.70049,31.410145],[121.700478,31.410303],[121.700445,31.410441],[121.698257,31.410285]],"type":"LineString"},"type":"Feature","properties":{}},{"geometry":{"coordinates":[[121.69812,31.409843],[121.698143,31.409519],[121.700527,31.409692],[121.700479,31.410019],[121.698123,31.409847]],"type":"LineString"},"type":"Feature","properties":{}},{"geometry":{"coordinates":[[121.698114,31.409371],[121.698147,31.409028],[121.700575,31.409207],[121.700542,31.409552],[121.698123,31.409378]],"type":"LineString"},"type":"Feature","properties":{}},{"geometry":{"coordinates":[[121.696878,31.411439],[121.696932,31.410937],[121.697815,31.411001],[121.697767,31.411515],[121.696878,31.411447]],"type":"LineString"},"type":"Feature","properties":{}},{"geometry":{"coordinates":[[121.695977,31.411383],[121.696023,31.410857],[121.696822,31.410916],[121.696769,31.411456],[121.695975,31.411393]],"type":"LineString"},"type":"Feature","properties":{}}],"type":"FeatureCollection"} diff --git a/src/views/page/largeScreen.vue b/src/views/page/largeScreen.vue index 2f3c3f56..6eb1c69f 100644 --- a/src/views/page/largeScreen.vue +++ b/src/views/page/largeScreen.vue @@ -769,7 +769,6 @@ export default { return formattedTime }, getData() { - console.log(this.dateRange); var data = { equipmentId:'2024070113400048', startTime: this.getdataTime(this.dateRange[0]), @@ -1324,24 +1323,11 @@ mapInit(){ satelliteLayer.setMap(map); // 加载卫星图层 // roadNetLayer.setMap(map); // 加载路网图层(覆盖在卫星图上) - // 添加标点 - const iconUrl = require("@/assets/img/axis1.png"); - const icon = new AMap.Icon({ - image: iconUrl, -size: new AMap.Size(70, 86), // 原始大小,如果不是原始大小,可以根据需要进行调整或忽略 - imageSize: new AMap.Size(35, 43) // 设置实际显示的大小为35x43像素 - }); - const marker = new AMap.Marker({ - position:new AMap.LngLat(121.696506, 31.410799), - icon: icon, - title: "上海前卫柑桔有限公司", - offset: new AMap.Pixel(-17.5, -40), //以 icon 的 [center bottom] 为原点 - }); + // 添加画范围 var listall = mapData.features; listall.forEach((el, index) => { - console.log(el,111); var polygon = new AMap.Polygon({ map: map, path: el.geometry.coordinates, //设置多边形边界路径 @@ -1373,7 +1359,28 @@ size: new AMap.Size(70, 86), // 原始大小,如果不是原始大小,可以 //将绘制的面对象添加到地图上 map.add(polygon); }); - map.add(marker); + + + // 添加标点 + const iconUrl = require("@/assets/img/axis1.png"); + const icon = new AMap.Icon({ + image: iconUrl, +size: new AMap.Size(70, 86), // 原始大小,如果不是原始大小,可以根据需要进行调整或忽略 + imageSize: new AMap.Size(35, 43) // 设置实际显示的大小为35x43像素 + }); + this.dataList.forEach((el,index)=>{ + if(el.xaxis&&el.yaxis){ + const marker = new AMap.Marker({ + position:new AMap.LngLat(el.xaxis,el.yaxis), + icon: icon, + title: "上海前卫柑桔有限公司", + offset: new AMap.Pixel(-17.5, -40), //以 icon 的 [center bottom] 为原点 + }); + map.add(marker); + } + + }) + }, // autoPlay1() { // this.autoPlay = false; diff --git a/src/views/page/largeScreen3.vue b/src/views/page/largeScreen3.vue index 23a9368d..b26e4d3c 100644 --- a/src/views/page/largeScreen3.vue +++ b/src/views/page/largeScreen3.vue @@ -316,7 +316,6 @@ export default { // 根据用户id查询对应的设备大数据信息 dataInit(userid, limitUserId) { this.api.Bigdata_getAllControl(userid).then((res) => { - console.log(111); // console.log('根据用户id查询对应的设备大数据信息', res); this.dataList = res.data.data; setTimeout(() => { @@ -348,7 +347,7 @@ export default { // 长兴前卫柑桔新优品种扩繁基地 id为13 有单独的虫情接口 this.getImage(); this.getCharts(); - + this.mapInit() } }); @@ -663,7 +662,7 @@ export default { // id == 5 大冶鑫; this.limitUserId = (res.data.data.filter(el => el.id == 2 || el.id == 1 || el.id == 5 || el.id == 7 || el.id == 8 || el.id == 9 || el.id == 10 || el.id == 11|| el.id == 12|| el.id == 13))[0].id; // this.drag_boxHandler13(); - this.mapInit() + this.dataInit(userId, this.limitUserId); } @@ -683,21 +682,27 @@ mapInit(){ satelliteLayer.setMap(map); // 加载卫星图层 // roadNetLayer.setMap(map); // 加载路网图层(覆盖在卫星图上) - // 添加标点 -const iconUrl = require("@/assets/img/axis1.png"); -const icon = new AMap.Icon({ - image: iconUrl, + + // 添加标点 + const iconUrl = require("@/assets/img/axis1.png"); + const icon = new AMap.Icon({ + image: iconUrl, size: new AMap.Size(70, 86), // 原始大小,如果不是原始大小,可以根据需要进行调整或忽略 imageSize: new AMap.Size(35, 43) // 设置实际显示的大小为35x43像素 -}); - -const marker = new AMap.Marker({ - position: new AMap.LngLat(121.696506, 31.410799), - icon: icon, - title: "上海前卫柑桔有限公司", - offset: new AMap.Pixel(-17.5, -43), // 关键修正点 - zIndex: 100, // 提高层级(避免被覆盖) -}); + }); + this.dataList.forEach((el,index)=>{ + + if(el.xaxis&&el.yaxis){ + var marker = new AMap.Marker({ + position:new AMap.LngLat(el.xaxis,el.yaxis), + icon: icon, + title: "上海前卫柑桔有限公司", + offset: new AMap.Pixel(-17.5, -40), //以 icon 的 [center bottom] 为原点 + }); + map.add(marker); + } + + }) // 添加画范围 var listall = mapData.features; listall.forEach((el, index) => { @@ -733,9 +738,7 @@ const marker = new AMap.Marker({ //将绘制的面对象添加到地图上 map.add(polygon); }); -map.on("complete", function() { - map.add(marker); -}); + }, diff --git a/vue.config.js b/vue.config.js index 5ced73b8..6cfc47b0 100644 --- a/vue.config.js +++ b/vue.config.js @@ -44,9 +44,9 @@ module.exports = { }, proxy: { "/api": { - target: 'https://api.lihe-control.com', //地址 + // target: 'https://api.lihe-control.com', //地址 // target: 'http://jiaxingtest.a1.luyouxia.net:21114', //地址 - // target: 'http://jiaxingtest.e1.luyouxia.top:19159', //地址 + target: 'http://jiaxingtest.e1.luyouxia.top:19159', //地址 // target: 'http://jiaxingtest.a1.luyouxia.net:25762', //地址 changeOrigin: true, pathRewrite: {