From fcf1ab7acf2517d4a9884bc785430769b099b064 Mon Sep 17 00:00:00 2001
From: quanyawei <401863037@qq.com>
Date: Tue, 10 Oct 2023 10:29:30 +0800
Subject: [PATCH] fix:风场粒子修改

---
 src/components/Wind/Map.vue |  159 ++++++++++++++++++++++++++++++++--------------------
 1 files changed, 98 insertions(+), 61 deletions(-)

diff --git a/src/components/Wind/Map.vue b/src/components/Wind/Map.vue
index 7578943..5414cfd 100644
--- a/src/components/Wind/Map.vue
+++ b/src/components/Wind/Map.vue
@@ -333,7 +333,6 @@
 import RegionalOverview from '@/components/Wind/RegionalOverview' // ������������������
 import { mapGetters } from 'vuex'
 import { gcj02towgs84 } from '@/assets/json/transform'
-import requestObj from '@/utils/request'
 export default {
   components: { RegionalOverview },
   props: {
@@ -464,7 +463,8 @@
       chooseTime: false,
       dateInfo: '', // ���������������
       timeInfo: '', // ���������������
-      nyr: '' // ������������������
+      nyr: '', // ������������������
+      windAllDate: []
     }
   },
   computed: {
@@ -480,6 +480,9 @@
     }
   },
   mounted() {
+    this.$nextTick(() => {
+      this.getParamsData()
+    })
     this.currentHour()
     this.$Bus.$on(
       'alarmTableVisible',
@@ -499,9 +502,9 @@
     this.jingduNew = newLL[1]
     this.weiduNew = newLL[0]
     // ���������������������
-    this.windData()
-    this.change(0)
-    this.getParamsData()
+    // this.windData()
+    // this.change(0)
+
     this.windDir()
     this.newDate()
     // this.alertData(this.PageSize, this.currentPage)
@@ -1524,7 +1527,7 @@
       this.getParamsData()
       setTimeout(() => {
         $.getJSON(
-          `${requestObj.baseUrl}/screen_api_v2/screen/windAndDeviceDataByArea`,
+          'http://47.99.64.149:8080/api/screen_api_v2/screen/windAndDeviceDataByArea',
           { monitorPointId: this.$store.state.monitorPointId },
           (data) => {
             // ������������������
@@ -1541,14 +1544,14 @@
           }
         )
       }, 1000)
-      if (this.windState === 1) {
-        // this.ws.close()
-        this.initData()
-        // console.log('���������������')
-      } else if (this.windState === 2) {
-        this.windDir()
-        // console.log('���������������')
-      }
+      // if (this.windState === 1) {
+      //   console.log('getRegionApiRequest')
+      //   this.initData()
+      // console.log('���������������')
+      // } else if (this.windState === 2) {
+      // this.windDir()
+      // console.log('���������������')
+      // }
       // ������������������
       // this.deviceMaker()
       // this.getParamsData()
@@ -1583,14 +1586,14 @@
           }
           // console.log(this.chooseTimeInfo, 'this.chooseTimeInfo ')
           // clearInterval(this.timer)
-          if (this.windState === 1) {
-            // this.ws.close()
-            this.initData()
-            // console.log('���������������')
-          } else if (this.windState === 2) {
-            this.windDir()
-            // console.log('���������������')
-          }
+          // if (this.windState === 1) {
+          // this.ws.close()
+          // this.initData()
+          // console.log('���������������')
+          // } else if (this.windState === 2) {
+          // this.windDir()
+          // console.log('���������������')
+          // }
           setTimeout(() => {
             this.change(this.changeColor)
             this.times = 300
@@ -1598,6 +1601,21 @@
         }
       }, 1000)
     },
+
+    findLayer(layerName) { // ������������������������������
+      if (!this.map) {
+        return null
+      }
+      const gisMap_layers = this.map._layers
+      let layer = null
+      for (const i in gisMap_layers) {
+        if (gisMap_layers[i].options.id === layerName) {
+          layer = gisMap_layers[i]
+        }
+      }
+      return layer
+    },
+
     // ���������������������
     initMap() {
       //   console.log('������index������map������������')
@@ -1609,7 +1627,11 @@
         center: [this.weiduNew, this.jingduNew],
         zoom: 14,
         zoomControl: false, // ������������
-        attributionControl: false, // ���������������logol
+        trackResize: true,
+        worldCopyJump: true,
+        dragging: true,
+        inertia: true,
+        attributionControl: true, // ���������������logol
         crs: L.CRS.EPSG3857 // ���������������������EPSG3857���������������������EPSG3395������������������������ EPSG4326 WGS84
       })
       // ������������������
@@ -1619,11 +1641,26 @@
       // L.tileLayer(
       //   'http://webrd01.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=7&x={x}&y={y}&z={z}'
       // ).addTo(map)
+      const that = this
       this.map = map // data���������������
+
+      this.map.on('moveend', function(ev) {
+        const res = that.findLayer('wmsid')
+        that.map.removeLayer(res)
+        that.openWindCanves()
+      })
+      // this.map.on('viewreset', function() {
+      //   console.log('--->viewreset ���������������������')
+      // })
       window.map = map
     },
     // ������������������������
     change(index) {
+      if (this.windState === 1) {
+        this.initData()
+      } else if (this.windState === 2) {
+        this.windDir()
+      }
       this.changeColor = index
       var pr = ''
       switch (index) {
@@ -1659,11 +1696,6 @@
       this.sensorKey = pr
       // ������������������
       // this.toggleWindState()
-      if (this.windState === 1) {
-        this.initData()
-      } else if (this.windState === 2) {
-        this.windDir()
-      }
     },
     // ���������������������
     initData() {
@@ -1684,11 +1716,11 @@
           }
         })
       }
+      this.windData()
       this.deviceMaker()
       //   console.log('������������������')
       // $.ajaxSettings.async = false
       // for (let i = 0; i < this.monitorPointIds.length; i++) {
-      this.windData()
       // }
     },
     // ���������������
@@ -1703,6 +1735,8 @@
         }
       })
         .then((res) => {
+          this.windAllDate = res.data[0]
+          this.openWindCanves()
           // console.log('���������������')
           // console.log(res)
           // if (res.data[0][0].data.length === 0) {
@@ -1718,38 +1752,6 @@
           // data2[0].header.dy = 0.0018464922
           // data2[1].header.dy = 0.0018464922
           // console.log(data2, 'data2')
-          var velocityLayer = L.velocityLayer({
-            displayValues: false, // ���������������������������������������������������
-            displayOptions: {
-              // ������������������
-              // velocityType: 'Global Wind',
-              velocityType: 'GBR Wind',
-              displayPosition: 'bottomleft',
-              displayEmptyString: 'No wind data'
-            },
-            data: res.data[0], // ������  ���������������
-            // data: data2,
-            // ������������������������������������������
-            minVelocity: 0, // ��������������������� m/s ���
-            maxVelocity: 8, // ��������������������� m/s ���
-            velocityScale: 0.1, // ��������������� ( ������������������������ )
-            particleAge: 90, // ������������������������������������������
-            lineWidth: 1.5, // ���������������������
-            particleMultiplier: 1 / 300, // ��������������������� ������������ ���
-            frameRate: 15, // ���������������������
-            colorScale: [
-              '#A2D839',
-              '#7EB530',
-              '#6E9F26',
-              '#4E7522',
-              '#345B1B',
-              '#186303',
-              '#175103',
-              '#053F03'
-            ]
-            // colorScale: ['#053F03', '#053F03', '#053F03', '#053F03', '#053F03', '#053F03', '#053F03', '#053F03']
-          })
-          velocityLayer.addTo(this.map) // ���������������
           // console.log('������������')
           // console.log(res.data[0])
         })
@@ -1757,6 +1759,41 @@
           console.log(err)
         })
     },
+    openWindCanves() {
+      var velocityLayer = L.velocityLayer({
+        displayValues: true, // ���������������������������������������������������
+        id: 'wmsid',
+        displayOptions: {
+          // ������������������
+          // velocityType: 'Global Wind',
+          velocityType: 'GBR Wind',
+          displayPosition: 'bottomleft',
+          displayEmptyString: 'No wind data'
+        },
+        data: this.windAllDate, // ������  ���������������
+        // data: data2,
+        // ������������������������������������������
+        minVelocity: 0, // ��������������������� m/s ���
+        maxVelocity: 8, // ��������������������� m/s ���
+        velocityScale: 0.1, // ��������������� ( ������������������������ )
+        particleAge: 90, // ������������������������������������������
+        lineWidth: 1.5, // ���������������������
+        particleMultiplier: 1 / 300, // ��������������������� ������������ ���
+        frameRate: 15, // ���������������������
+        colorScale: [
+          '#A2D839',
+          '#7EB530',
+          '#6E9F26',
+          '#4E7522',
+          '#345B1B',
+          '#186303',
+          '#175103',
+          '#053F03'
+        ]
+        // colorScale: ['#053F03', '#053F03', '#053F03', '#053F03', '#053F03', '#053F03', '#053F03', '#053F03']
+      })
+      velocityLayer.addTo(this.map) // ���������������
+    },
     // ������������������������������������������������������������������
     alertData(n1, n2) {
       // ������������axios���������������������������

--
Gitblit v1.8.0