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
| /**
| * 动态效果封装
| */
| class AnimalService {
| constructor (config) {
| this.intervals = [] // 定时器列表
| // todo 这种情况一般用 window级的L、map还是传递呢
| this.L = config.L
| this.layer = window.map
| 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
|
|