/** * 固废 */ // 区分不同类型 使用不同img const defaultImg = '/assets/images/map/solidwaste/voc.png' const setting = '/assets/images/map/solidwaste/gf_green.png' const mapApi = require('../../../api/mapApi').default const AnimalService = require('../service/AnimalService').default module.exports = function () { /** * 返回marker对象数组 * @param L leaflet对象 */ this.init = async (layer, L) => { this.animalService = new AnimalService({ L: L, layer: layer }) const res = await mapApi.getSolidWaste() // console.log(res) const data = res.Result.DataInfo || {} for (let i = 0; i < data.length; i++) { // 经纬度 位置 const positionX = data[i].Latitude const positionY = data[i].Longitude // 定义类型 用来区分数据的不同 const judgeValue = data[i].StorageQty var iconUrl = this.differentTypes(judgeValue) const marker = L.marker.magic([positionX, positionY], { icon: L.icon({ iconUrl: iconUrl, iconSize: [50, 50], iconAnchor: [25, 25] }) }) layer.addLayer(marker) } } this.bindTooltip = (layer) => { return '测试固废' } this.clickListener = (e) => { this.animalService.pulseEffect(e.latlng) console.log(e) return this.PublicBounced.$el } // 不同类型图片封装 this.differentTypes = (judgeValue) => { var effectOfChange if (judgeValue === 1) { effectOfChange = defaultImg } else { effectOfChange = setting } return effectOfChange } // 固废点击进行的 内容的设置 // SetSolidWasteContent (config, containerPopup) { // this.SolidWastePopup = containerPopup // } }