From 9185072c775eaf1cd3df53d06bc81dc5bfc8264b Mon Sep 17 00:00:00 2001
From: chenyibo <p-honggang.li@pcitc.com>
Date: 星期二, 30 三月 2021 16:31:58 +0800
Subject: [PATCH] Merge branch 'develop' of http://xearth.cn:6600/r/wuyushui/SewerAndRainNetwork into develop

---
 src/components/BaseNav/SolidWaste/SolidWaste.js |  182 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 182 insertions(+), 0 deletions(-)

diff --git a/src/components/BaseNav/SolidWaste/SolidWaste.js b/src/components/BaseNav/SolidWaste/SolidWaste.js
new file mode 100644
index 0000000..6df5e3e
--- /dev/null
+++ b/src/components/BaseNav/SolidWaste/SolidWaste.js
@@ -0,0 +1,182 @@
+import { QueryStoragePlaceListByCompanyAndName } from '@/api/request'
+// 灞曠ず鍥剧墖
+import defaultImg from '@assets/images/map-pages/basenav/solidwaste/voc.png'
+import Setting from '@assets/images/map-pages/basenav/solidwaste/gf_green.png'
+
+// 搴曞浘涓氬姟灞曠ず鐐�
+class AddSolidWasteHelper {
+  constructor (options) {
+    this.map = options.map
+    this.L = window.L
+    this.SolidWasteLayerGroup = this.L.layerGroup().addTo(this.map)
+    this.SolidWastePopup = null
+    this.L.sgis = this.L.sgis || this.L
+    this.solidWasteMarkersLabels = []
+    this.pulseHeighLightMarker = null
+  }
+
+  // 璇锋眰鏁版嵁 data 涓哄弬鏁帮紝 璇锋眰鍚庡彴鏁版嵁鏃� 鎼哄甫data鍙傛暟
+  requestData (data) {
+    QueryStoragePlaceListByCompanyAndName(data).then(res => {
+      // console.log(res)
+      this.DrawTheSolidWasteContent(res.Result.DataInfo)
+    }).catch(err => {
+      console.log(err)
+    })
+  }
+
+  // 鏍规嵁鑾峰彇鏁版嵁 鐢诲嚭 鍐呭
+  DrawTheSolidWasteContent (data) {
+    // 鍥炬爣鏍峰紡鎵╁睍
+    var SolidWasteIcon = this.SolidWasteIcon()
+
+    // //鍔犺浇鏁版嵁鍓嶅鏋滃瓨鍦ㄥ浘灞傜粍 閭d箞娓呴櫎鎺�
+    if (this.SolidWasteLayerGroup) {
+      this.SolidWasteLayerGroup.clearLayers()
+    }
+    for (let i = 0; i < data.length; i++) {
+      // 缁忕含搴� 浣嶇疆
+      const positionX = data[i].Latitude
+      const positionY = data[i].Longitude
+
+      // 鍒ゆ柇 缁忕含搴︿綅缃俊鎭槸鍚﹀瓨鍦�
+      if (positionX != null && positionY != null) {
+        // 鐢ㄤ簬 鍒ゆ柇 => 鍒ゆ柇鏄惁灞曠ず鑴夊啿鏁堟灉 => temp(涓存椂)
+        const determineValueOne = data[i].LongDayWarning
+        var determineValueTwo = data[i].StorageQty
+        const positionArea = [positionX, positionY]
+
+        // 鍥炬爣灞曠ず
+        var iconUrl = this.SolidWasteIconUrl(determineValueOne, determineValueTwo, positionArea)
+        var Icon = new SolidWasteIcon({ iconUrl: iconUrl })
+        // var url = Icon.options.iconUrl
+
+        const marker = this.L.marker([positionX, positionY], { icon: Icon })
+        // 鍒掕繃鍑虹幇 灞曠ず鏁版嵁
+        marker.bindTooltip(data[i].Name, {
+          permanent: true,
+          offset: [0, -16],
+          direction: 'top',
+          className: ''
+        })
+        // 鐐瑰嚮 浜嬩欢
+        marker.on('click', (e) => {
+          try {
+            // console.log(e)
+            // console.log(this.map.getCenter())
+            // console.log(this.map.setCenter([e.target.getLatLng().lat, e.target.getLatLng().lng]))
+            // this.map.flyTo([e.target.getLatLng().lat, e.target.getLatLng().lng])
+            // this.map.panTo([e.target.getLatLng().lat, e.target.getLatLng().lng], 100)
+            this.setPanTo(e.target.getLatLng(), 30)
+            this.EffectOfPulse(e.target.getLatLng())
+            this.SolidWastePopup.setData(data[i], 'gufei')
+            return this.SolidWastePopup.$el
+          } catch (error) {
+            console.log(error)
+          }
+        })
+        // 璁剧疆鍐呭娣诲姞鍒板浘灞�
+        this.SolidWasteLayerGroup.addLayer(marker)
+      }
+    }
+  }
+
+  // panTo
+  setPanTo (pos, value) {
+    var position = pos
+    position = this.map.latLngToLayerPoint(position)
+    position.y += value
+    position = this.map.layerPointToLatLng(position)
+    this.map.setView(position)
+    // this.map.flyTo(position)
+  }
+
+  // 鍥哄簾鐐瑰嚮杩涜鐨� 鍐呭鐨勮缃�
+  SetSolidWasteContent (config, containerPopup) {
+    this.SolidWastePopup = containerPopup
+  }
+
+  // 鍥炬爣鏍峰紡鎵╁睍 => 鍏夊湀 鍥炬爣鑴夊啿
+  SolidWasteIcon () {
+    return this.L.Icon.extend({
+      options: {
+        iconSize: [50, 50],
+        iconAnchor: [25, 25]
+      }
+    })
+  }
+
+  // 鏍规嵁绫诲瀷杩斿洖鍥剧墖鍔犺浇url
+  SolidWasteIconUrl (determineValueOne, determineValueTwo, position) {
+    var EffectOfChange
+    if (determineValueOne === 1 || determineValueTwo === 1) {
+      EffectOfChange = defaultImg
+      this.EffectOfPulse(position, this.solidWasteMarkersLabels, this.SolidWasteLayerGroup)
+    } else {
+      EffectOfChange = Setting
+    }
+    return EffectOfChange
+  }
+
+  // 鑴夊啿鏁堟灉璁剧疆瀹炵幇
+  EffectOfPulse (position, markers, layerGroup) {
+    // 鍖哄垎鐩存帴鎵ц 鍜屽垽鏂墽琛岀殑涓嶅悓鍖哄埆
+    var differentColor = ''
+    if (markers) {
+      differentColor = '#ff0000'
+    } else {
+      differentColor = '#98FB98'
+    }
+    // 鍧愭爣鏁版嵁锛氭姤璀︿紶杩涙潵鐨勬槸鏁扮粍 / 鐐瑰嚮浼犺繘鏉ョ殑鏄痮bject
+    var FinalPosition = position instanceof Array ? {
+      lat: position[0],
+      lng: position[1]
+    } : position
+    // 鎻掍欢 鏁堟灉瀹炵幇
+    var pulsingIcon = this.L.icon.pulse({
+      iconSize: [20, 20],
+      color: differentColor,
+      fillColor: ''
+    })
+    if (markers) {
+      // markers.push(this.L.marker(FinalPosition, { icon: pulsingIcon }))
+      // this.L.layerGroup(markers).addLayer(layerGroup)
+    } else {
+      var picGroupMarker = new this.L.FeatureGroup()
+      this.L.marker(FinalPosition, { icon: pulsingIcon }).addTo(picGroupMarker)
+      this.pulseHeighLightMarker = picGroupMarker.addTo(this.SolidWasteLayerGroup)
+      this.PulseCountSetting()
+    }
+  }
+
+  // 瀵瑰浘鏍囪剦鍐� 杩涜set璁剧疆  // 楂樹寒鍥惧眰
+  PulseCountSetting () {
+    var HeightLightTime = 5
+    var PulseNumber = 5
+    const pulseinterver = setInterval((e) => {
+      if (PulseNumber > 0) {
+        PulseNumber--
+      } else {
+        this.pulseClear(pulseinterver)
+        PulseNumber = HeightLightTime
+      }
+    }, 1000)
+  }
+
+  // 娓呴櫎 鍥惧眰
+  pulseClear (pulseinterver) {
+    clearInterval(pulseinterver)
+    pulseinterver = null
+
+    if (this.SolidWasteLayerGroup) {
+      // this.SolidWasteLayerGroup.clearLayers()
+    } else {
+      this.SolidWasteLayerGroup = this.L.layerGroup().addTo(this.map)
+    }
+    if ((this.pulseHeighLightMarker)) {
+      this.pulseHeighLightMarker.remove()
+    }
+  }
+}
+
+export default AddSolidWasteHelper

--
Gitblit v1.8.0