派生自 wuyushui/SewerAndRainNetwork

徐旺旺
2021-05-08 f99fd37cdbaaa4f09e5b7383442ee264fd332232
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
/**
 * 加载业务数据图层
 */
import { logicMapper } from '@src/conf/Constants'
 
class BusiLayerService {
  constructor (config) {
    this.L = window.L
    this.map = window.map
    this.config = config
  }
 
  init (layer) {
    // 引入 关联的js,在constant.js中根据config配置的id得到处理js
    const id = this.config.code
    console.log(id)
    const file = logicMapper[id]
    if (!file) {
      console.log('找不到逻辑处理js!!!' + id)
    } else {
      var BusiLayer = require('../logic/' + file)
      var busiLayer = new BusiLayer()
      busiLayer.init(layer, this.L)
      if (busiLayer.bindTooltip) {
        // 全局tips位置
        layer.bindTooltip(busiLayer.bindTooltip, { direction: 'top', offset: [0, -15], sticky: false })
      }
      // 调用click事件
      if (busiLayer.clickListener) {
        layer.on('click', busiLayer.clickListener)
      }
      layer.addTo(this.map)
    }
  }
}
 
export default BusiLayerService