瀏覽代碼

Merge branch 'master' of http://www.sysuimars.cn:3000/feiniao/feiniao-pc-vue

wangsisi 2 月之前
父節點
當前提交
0f371b0b23
共有 3 個文件被更改,包括 19 次插入18 次删除
  1. 1 0
      src/views/warningHome/index.vue
  2. 15 15
      src/views/warningHome/map/mockFarmLayer.js
  3. 3 3
      src/views/warningHome/warningMap.js

+ 1 - 0
src/views/warningHome/index.vue

@@ -66,6 +66,7 @@
 </template>
 
 <script setup>
+import "./map/mockFarmLayer"
 import { onMounted, ref } from "vue";
 import fnHeader from "@/components/fnHeader.vue";
 import WarningMap from "./warningMap";

+ 15 - 15
src/views/home/map/mockFarmLayer.js → src/views/warningHome/map/mockFarmLayer.js

@@ -42,21 +42,21 @@ class MockFarmLayer {
             },
             zIndex:-1
         });
-        // eventBus.on("homeMap:init", function (kmap) {
-        //     that.initLayer(kmap)
-        //     VE_API.farm.weatherRiskVirtualFarmList().then(res => {
-        //         if(res.code ===0){
-        //             that.setData(res.data)
-        //         }
-        //     })
-        // })
-        // eventBus.on("MockFarmLayer:click", function ({event, feature}) {
-        //     let targetSampleId = feature.get("targetSampleId")
-        //     let mockFarmId = feature.get("mockFarmId")
-        //     // let lonLat = event.map.getCoordinateFromPixel(event.pixel);
-        //     // console.log('纬度:', lonlat[1]);
-        //     router.push({path:'feature_album',query:{farmId:mockFarmId,sampleId:targetSampleId,timestamp: Date.now()}})
-        // })
+        eventBus.on("warningMap:init", function (kmap) {
+            that.initLayer(kmap)
+            VE_API.mini_farm.weatherRiskVirtualFarmList().then(res => {
+                if(res.code ===0){
+                    that.setData(res.data)
+                }
+            })
+        })
+        eventBus.on("MockFarmLayer:click", function ({event, feature}) {
+            let targetSampleId = feature.get("targetSampleId")
+            let mockFarmId = feature.get("mockFarmId")
+            // let lonLat = event.map.getCoordinateFromPixel(event.pixel);
+            // console.log('纬度:', lonlat[1]);
+            router.push({path:'feature_album',query:{farmId:mockFarmId,sampleId:targetSampleId,timestamp: Date.now()}})
+        })
     }
 
 

+ 3 - 3
src/views/warningHome/warningMap.js

@@ -8,7 +8,7 @@ import WKT from "ol/format/WKT.js";
 import ScaleLine from "ol/control/ScaleLine";
 import { useRouter } from "vue-router";
 import Overlay from 'ol/Overlay'
-
+import eventBus from "@/api/eventBus";
 /**
  * @description 地图层对象
  */
@@ -23,7 +23,7 @@ class HomeMap {
     let level = 6;
     let coordinate = util.wktCastGeom(location).getFirstCoordinate();
     this.kmap = new KMap.Map(target, level, coordinate[0], coordinate[1], null, 6, 22);
-
+    eventBus.emit('warningMap:init', this.kmap);
     this.addPopup()
     this.addMapListen()
   }
@@ -59,7 +59,7 @@ class HomeMap {
         that.popup.setPosition(event.coordinate); // 设置弹窗位置为点击位置
       } else {
         // that.popup.setPosition(undefined); // 如果没有点击到feature,则隐藏弹窗
-        
+
         // 在这里可以获取feature的属性,并显示在弹窗中
         let content = '<div>';
         // for (let key in feature.getProperties()) {