派生自 wuyushui/SewerAndRainNetwork

wangqi
2021-03-31 2219d26b186bd56616fa9b45432837378c894551
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
/**
 * 动态效果封装
 */
class AnimalService {
  constructor (config) {
    this.intervals = [] // 定时器列表
    this.L = config.L
    this.layer = config.layer
    this.times = config.times || 5
    this.colors = ['#98FB98', '#ff0000']
  }
 
  /**
   * 脉冲效果
   */
  pulseEffect (xy) {
    // 插件 效果实现
    var pulsingIcon = this.L.icon.pulse({
      iconSize: [20, 20],
      color: this.colors[0],
      fillColor: ''
    })
    var picGroupMarker = this.L.marker(xy, { icon: pulsingIcon }).addTo(this.layer)
    var times = this.times
    // 定时
    var timeInterval = setInterval(() => {
      if (times > 0) {
        times--
      } else {
        clearInterval(timeInterval)
        picGroupMarker.remove()
      }
    }, 1000)
  }
}
 
export default AnimalService