From 7b4d8a5ee0cae50a5f473e3765ba84f28fe8ba4b Mon Sep 17 00:00:00 2001
From: zhangshuaibao <15731629597@163.com>
Date: 星期一, 29 三月 2021 11:27:54 +0800
Subject: [PATCH] Merge branch 'develop' of http://xearth.cn:6600/r/wuyushui/SewerAndRainNetwork into develop
---
src/components/flueGas/flueGas.js | 176 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 176 insertions(+), 0 deletions(-)
diff --git a/src/components/flueGas/flueGas.js b/src/components/flueGas/flueGas.js
new file mode 100644
index 0000000..62f103f
--- /dev/null
+++ b/src/components/flueGas/flueGas.js
@@ -0,0 +1,176 @@
+import { FlueGas } from '@/api/request'
+import defaultImg from '@components/flueGas/green_airquality_2.png'
+import Setting from '@components/flueGas/green_airquality_3.png'
+// 鍥剧墖
+
+class AddGasHelper {
+ constructor (options) {
+ this.map = options.map
+ this.L = window.L
+ this.FlueGasLayerGroup = this.L.layerGroup().addTo(this.map)
+ this.FlueGasPopup = null
+ this.L.sgis = this.L.sgis || this.L
+ this.FlueGasMarkersLabels = []
+ this.pulseHeighLightMarker = null
+ }
+
+ // 鑾峰彇鏁版嵁
+ requestData (data) {
+ FlueGas(data).then(res => {
+ console.log(res)
+ this.DrawFlueGasContent(res.Result.DataInfo)
+ }).catch(err => {
+ console.log(err)
+ })
+ }
+
+ // 鏍规嵁鑾峰彇鏁版嵁 鐢诲嚭 鍐呭
+ DrawFlueGasContent (data) {
+ // 鍥炬爣鏍峰紡鎵╁睍
+ var FlueGasIcon = this.PlueGasIcon()
+
+ // //鍔犺浇鏁版嵁鍓嶅鏋滃瓨鍦ㄥ浘灞傜粍 閭d箞娓呴櫎鎺�
+ if (this.FlueGasLayerGroup) {
+ this.FlueGasLayerGroup.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.PlueGasIconUrl(determineValueOne, determineValueTwo, positionArea)
+ var Icon = new FlueGasIcon({ iconUrl: iconUrl })
+ // var url = Icon.options.iconUrl
+
+ const marker = this.L.marker([positionX, positionY], { icon: Icon })
+ // const latlngs = positionArea[2]
+ // // 绾�
+ // var polyline = this.L.polyline(latlngs, { color: 'red' }).addTo(this.map)
+ // console.log(polyline)
+ marker.bindPopup(() => {
+ return this.FlueGasPopup.$el
+ }, {
+ className: 's-map-popup',
+ minWidth: 1548,
+ closeButton: true,
+ autoClose: false
+ })
+ // 鍒掕繃鍑虹幇 灞曠ず鏁版嵁
+ marker.bindTooltip(data[i].porltName, {
+ permanent: true,
+ offset: [0, -16],
+ direction: 'top',
+ className: ''
+ })
+ // 鐐瑰嚮 浜嬩欢
+ marker.on('click', (e) => {
+ try {
+ // console.log(e)
+ this.EffectOfPulse(e.target.getLatLng())
+ this.FlueGasPopup.setDate(data[i])
+ } catch (error) {
+ console.log(error)
+ }
+ })
+ // 璁剧疆鍐呭娣诲姞鍒板浘灞�
+ this.FlueGasLayerGroup.addLayer(marker)
+ // }
+ }
+ }
+
+ // 鐐瑰嚮杩涜鐨� 鍐呭鐨勮缃�
+ SetPlueGasContent (config, containerPopup) {
+ this.FlueGasPopup = containerPopup
+ }
+
+ // 鍥炬爣鏍峰紡鎵╁睍 => 鍏夊湀 鍥炬爣鑴夊啿
+ PlueGasIcon () {
+ return this.L.Icon.extend({
+ options: {
+ iconSize: [50, 50],
+ iconAnchor: [25, 25]
+ }
+ })
+ }
+
+ // 鏍规嵁绫诲瀷杩斿洖鍥剧墖鍔犺浇url
+ PlueGasIconUrl (determineValueOne, determineValueTwo, position) {
+ var EffectOfChange
+ if (determineValueOne === 1 || determineValueTwo === 1) {
+ EffectOfChange = defaultImg
+ this.EffectOfPulse(position, this.FlueGasMarkersLabels, this.pulseHeighLightMarker)
+ } else {
+ EffectOfChange = Setting
+ }
+ return EffectOfChange
+ }
+
+ // 鑴夊啿鏁堟灉璁剧疆瀹炵幇
+ EffectOfPulse (position, markers, layerGroup) {
+ // // 鍖哄垎鐩存帴鎵ц 鍜屽垽鏂墽琛岀殑涓嶅悓鍖哄埆
+ let 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.FlueGasLayerGroup)
+ this.PulseCountSetting()
+ }
+ }
+
+ PulseCountSetting () {
+ var HeightLightTime = 5
+ var PulseNumber = 5
+ const pulseinterver = setInterval(() => {
+ if (PulseNumber > 0) {
+ PulseNumber--
+ } else {
+ this.pulseClear(pulseinterver)
+ PulseNumber = HeightLightTime
+ }
+ }, 1000)
+ }
+
+ // 娓呴櫎 鍥惧眰
+ pulseClear (pulseinterver) {
+ clearInterval(pulseinterver)
+ pulseinterver = null
+
+ if (this.PlueGasLayerGroup) {
+ // this.PlueGasLayerGroup.clearLayers()
+ } else {
+ this.PlueGasLayerGroup = this.L.layerGroup().addTo(this.map)
+ }
+ if ((this.pulseHeighLightMarker)) {
+ this.pulseHeighLightMarker.remove()
+ }
+ }
+}
+
+export default AddGasHelper
--
Gitblit v1.8.0