派生自 wuyushui/SewerAndRainNetwork

seatonwan9
2021-05-30 cca4ca2151f5f2c721662691f2ff5eb4f27147bb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
 * 污染源
 */
// 信息组件
// const SourcePollutionIndex = require('../../base-page/RiskSource/RiskSourceIndex.vue').default
// 使用封装方法
const AnimalService = require('../service/AnimalService').default
// 请求接口数据
const mapApi = require('../../../api/mapApi').default
// 公共方法 panTo() 引用
// const { setPanTo } = require('../../../utils/utils')
 
module.exports = function () {
  /**
   * 初始化并加载图层
   * @param L leaflet对象
   */
  this.init = async (layer, L) => {
    this.animalService = new AnimalService({
      L: L,
      layer: layer
    })
    const result = await mapApi.getEnvironmentRiskPoint()
    const data = result[0]
    for (let i = 0; i < data.length; i++) {
      const postion = [data[i].Latitude, data[i].Longitude] // 坐标
      const iconUrl = this.sourcePollutionIconUrl(1) // 治理设施图标
      const marker = L.marker(postion, {
        totransferData: data[i],
        icon: L.icon({
          iconUrl: iconUrl,
          iconSize: [20, 20],
          iconAnchor: [10, 10]
        })
      })
      layer.addLayer(marker)
    }
  }
 
  /**
   * 治理设施图标配置
   * @param t
   * @returns {string}
   */
  this.sourcePollutionIconUrl = (t) => {
    let iconUrl = null
    switch (t) {
      case 1:
        iconUrl = ''
        break
      case 2:
        iconUrl = ''
        break
      default:
        iconUrl = ''
        break
    }
    return iconUrl
  }
}