From 6ab6b11a0ba0bc20c099b9f7b73e9d03fe7d5b8e Mon Sep 17 00:00:00 2001
From: 徐旺旺 <11530253@qq.com>
Date: 星期一, 29 三月 2021 18:13:02 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/develop' into develop
---
src/components/BaseNav/WasteWater/WasteWater.js | 177 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 177 insertions(+), 0 deletions(-)
diff --git a/src/components/BaseNav/WasteWater/WasteWater.js b/src/components/BaseNav/WasteWater/WasteWater.js
new file mode 100644
index 0000000..c2f3d6b
--- /dev/null
+++ b/src/components/BaseNav/WasteWater/WasteWater.js
@@ -0,0 +1,177 @@
+import { requestWasteWater } from '@/api/request'
+// 灞曠ず鍥剧墖
+import defaultImg from '@assets/images/map-pages/basenav/Waste-water/fs_green.png'
+import Setting from '@assets/images/map-pages/basenav/Waste-water/fs_yellow.png'
+
+// 搴曞浘涓氬姟灞曠ず鐐�
+class AddWasteWaterHelper {
+ constructor (options) {
+ this.map = options.map
+ this.L = window.L
+ this.WasteWaterLayerGroup = this.L.layerGroup().addTo(this.map)
+ this.WasteWaterPopup = null
+ this.L.sgis = this.L.sgis || this.L
+ this.WasteWaterMarkersLabels = []
+ this.pulseHeighLightMarker = null
+ }
+
+ // 璇锋眰鏁版嵁 data 涓哄弬鏁帮紝 璇锋眰鍚庡彴鏁版嵁鏃� 鎼哄甫data鍙傛暟
+ requestData (data) {
+ requestWasteWater(data).then(res => {
+ console.log(res)
+ this.DrawWasteWaterContent(res.Result.DataInfo)
+ // console.log(res)
+ }).catch(err => {
+ console.log(err)
+ })
+ }
+
+ // 鏍规嵁鑾峰彇鏁版嵁 鐢诲嚭 鍐呭
+ DrawWasteWaterContent (data) {
+ // 鍥炬爣鏍峰紡鎵╁睍
+ const WasteWaterIcon = this.WasteWaterIcon()
+
+ // //鍔犺浇鏁版嵁鍓嶅鏋滃瓨鍦ㄥ浘灞傜粍 閭d箞娓呴櫎鎺�
+ if (this.WasteWaterLayerGroup) {
+ this.WasteWaterLayerGroup.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
+ const determineValueTwo = data[i].StorageQty
+ const positionArea = [positionX, positionY]
+
+ // 鍥炬爣灞曠ず
+ const iconUrl = this.WasteWaterIconUrl(determineValueOne, determineValueTwo, positionArea)
+ const Icon = new WasteWaterIcon({ iconUrl: iconUrl })
+ // let url = Icon.options.iconUrl
+
+ const marker = this.L.marker.magic([positionX, positionY], { icon: Icon, magic: 'vanishIn' })
+
+ marker.bindPopup(() => {
+ return this.WasteWaterPopup.$el
+ }, {
+ className: 's-map-popup',
+ minWidth: 1000,
+ closeButton: true,
+ autoClose: false
+ })
+ // 鍒掕繃鍑虹幇 灞曠ず鏁版嵁
+ marker.bindTooltip(data[i].Name, {
+ permanent: true,
+ offset: [0, -16],
+ direction: 'top',
+ className: ''
+ })
+ // 鐐瑰嚮浜嬩欢
+ marker.on('click', (e) => {
+ try {
+ // console.log(e)
+ this.EffectOfPulse(e.target.getLatLng())
+ this.WasteWaterPopup.setDate(data[i])
+ return this.WasteWaterPopup.$el
+ } catch (error) {
+ console.log(error)
+ }
+ })
+ // 璁剧疆鍐呭娣诲姞鍒板浘灞�
+ this.WasteWaterLayerGroup.addLayer(marker)
+ // }
+ }
+ }
+
+ // 搴熸按鎸夐挳鐐瑰嚮杩涜鐨� 鍐呭鐨勮缃�
+ SetWasteWaterContent (config, containerPopup) {
+ this.WasteWaterPopup = containerPopup
+ }
+
+ // 鍥炬爣鏍峰紡鎵╁睍 => 鍏夊湀 鍥炬爣鑴夊啿
+ WasteWaterIcon () {
+ return this.L.Icon.extend({
+ options: {
+ iconSize: [50, 50],
+ iconAnchor: [25, 25]
+ }
+ })
+ }
+
+ // 鏍规嵁绫诲瀷杩斿洖鍥剧墖鍔犺浇url
+ WasteWaterIconUrl (determineValueOne, determineValueTwo, position) {
+ let EffectOfChange
+ if (determineValueOne === 1 || determineValueTwo === 1) {
+ EffectOfChange = defaultImg
+ this.EffectOfPulse(position, this.WasteWaterMarkersLabels, this.WasteWaterLayerGroup)
+ } else {
+ EffectOfChange = Setting
+ }
+ return EffectOfChange
+ }
+
+ // 鑴夊啿鏁堟灉璁剧疆瀹炵幇
+ EffectOfPulse (position, markers, layerGroup) {
+ // // 鍖哄垎鐩存帴鎵ц 鍜屽垽鏂墽琛岀殑涓嶅悓鍖哄埆
+ let differentColor = ''
+ if (markers) {
+ differentColor = '#ff0000'
+ } else {
+ differentColor = '#98FB98'
+ }
+ // 鍧愭爣鏁版嵁锛氭姤璀︿紶杩涙潵鐨勬槸鏁扮粍 / 鐐瑰嚮浼犺繘鏉ョ殑鏄痮bject
+ const FinalPosition = position instanceof Array ? {
+ lat: position[0],
+ lng: position[1]
+ } : position
+ // 鎻掍欢 鏁堟灉瀹炵幇
+ const 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 {
+ const picGroupMarker = new this.L.FeatureGroup()
+ this.L.marker(FinalPosition, { icon: pulsingIcon }).addTo(picGroupMarker)
+ this.pulseHeighLightMarker = picGroupMarker.addTo(this.WasteWaterLayerGroup)
+ this.PulseCountSetting()
+ }
+ }
+
+ // 瀵瑰浘鏍囪剦鍐� 杩涜set璁剧疆 // 楂樹寒鍥惧眰
+ PulseCountSetting () {
+ const HeightLightTime = 5
+ let PulseNumber = 5
+ const pulseinterver = setInterval(() => {
+ if (PulseNumber > 0) {
+ PulseNumber--
+ } else {
+ this.pulseClear(pulseinterver)
+ PulseNumber = HeightLightTime
+ }
+ }, 1000)
+ }
+
+ // 鍦ㄦ墽琛屼笅涓墠娓呴櫎宸插瓨鍦ㄥ浘灞�
+ pulseClear (pulseinterver) {
+ clearInterval(pulseinterver)
+ pulseinterver = null
+
+ if (this.WasteWaterLayerGroup) {
+ // this.WasteWaterLayerGroup.clearLayers()
+ } else {
+ this.WasteWaterLayerGroup = this.L.layerGroup().addTo(this.map)
+ }
+ if ((this.pulseHeighLightMarker)) {
+ this.pulseHeighLightMarker.remove()
+ }
+ }
+}
+
+export default AddWasteWaterHelper
--
Gitblit v1.8.0