/** * 动态效果封装 */ 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