| | |
| | | /** |
| | | * 固废 |
| | | */ |
| | | |
| | | // 区分不同类型 使用不同img |
| | | const defaultImg = '/assets/images/map/solidwaste/voc.png' |
| | | const setting = '/assets/images/map/solidwaste/gf_green2.png' |
| | | |
| | | // 请求接口数据 |
| | | const mapApi = require('../../../api/mapApi').default |
| | | // 使用封装方法 |
| | | const AnimalService = require('../service/AnimalService').default |
| | | const AjaxUtils = require('../../../utils/AjaxUtils').default |
| | | |
| | | const publicBounced = require('../../BaseNav/PublicBounced/PublicBounced').default |
| | | |
| | | module.exports = function () { |
| | | /** |
| | | * 返回marker对象数组 |
| | | * @param L leaflet对象 |
| | | */ |
| | | this.init = (layer, L) => { |
| | | this.init = async (layer, L) => { |
| | | this.animalService = new AnimalService({ |
| | | L: L, |
| | | layer: layer, |
| | | LayerPopup: null |
| | | layer: layer |
| | | }) |
| | | // AjaxUtils.get4JsonDataByUrl('http://10.246.162.140:8080/EPInterface/DataService/EPMapService.asmx/QueryStoragePlaceListByCompanyAndName', { |
| | | // AjaxUtils.get4JsonDataByUrl('http://xearth.cn:3000/wasteSolid/getSolidWaste', { |
| | | AjaxUtils.get4JsonDataByUrl('http://localhost:8888/static/SolidWaste.json', { |
| | | companyId: 3900100145, |
| | | userCode: 'wenchun.deng', |
| | | name: '', |
| | | marginWarr: '', |
| | | longDayWarr: '' |
| | | }, function (res) { |
| | | const data = res.data.Result.DataInfo |
| | | for (let i = 0; i < data.length; i++) { |
| | | // 经纬度 位置 |
| | | const positionX = data[i].Latitude |
| | | const positionY = data[i].Longitude |
| | | layer.addLayer(L.marker([positionX, positionY], {})) |
| | | } |
| | | }) |
| | | const result = await mapApi.getSolidWaste() |
| | | const getSolidWasteData = result.Result.DataInfo || {} |
| | | // 循环遍历数据 根据进行marker 的创建 |
| | | for (let i = 0; i < getSolidWasteData.length; i++) { |
| | | // 经纬度 位置 |
| | | const positionX = getSolidWasteData[i].Latitude |
| | | const positionY = getSolidWasteData[i].Longitude |
| | | |
| | | // 定义类型 用来区分数据的不同 1.接口接口数据来进行数据的判断 2.根据数据类型的不同,进行不同类型的图片显示 |
| | | const judgeValue = getSolidWasteData[i].StorageQty |
| | | var iconUrl = this.differentTypes(judgeValue) |
| | | |
| | | const marker = L.marker([positionX, positionY], { |
| | | totransferData: getSolidWasteData[i], |
| | | icon: L.icon({ |
| | | iconUrl: iconUrl, |
| | | iconSize: [30, 30], |
| | | iconAnchor: [15, 15] |
| | | }) |
| | | }) |
| | | layer.addLayer(marker) |
| | | } |
| | | } |
| | | |
| | | this.bindTooltip = (layer) => { |
| | | return '测试固废' |
| | | return layer.options.totransferData.Name |
| | | } |
| | | |
| | | this.clickListener = (e) => { |
| | | // 点击marker的pulse()光波 |
| | | this.animalService.pulseEffect(e.latlng) |
| | | console.log(e) |
| | | console.log(this.PublicBounced) |
| | | // return this.PublicBounced.$el |
| | | /* 点击数据的接口请求 */ |
| | | this.requestSolidWasteData(e).then(e) |
| | | } |
| | | // 固废点击进行的 内容的设置 |
| | | // SetSolidWasteContent (config, containerPopup) { |
| | | // this.SolidWastePopup = containerPopup |
| | | // } |
| | | |
| | | // 不同类型图片封装 |
| | | this.differentTypes = (judgeValue) => { |
| | | var effectOfChange |
| | | if (judgeValue === 1) { |
| | | effectOfChange = defaultImg |
| | | } else { |
| | | effectOfChange = setting |
| | | } |
| | | return effectOfChange |
| | | } |
| | | |
| | | // 根据点击不同数据 进行接口的数据请求 |
| | | this.requestSolidWasteData = async (e) => { |
| | | // 基本信息 和 详细信息 展示数据所需参数 |
| | | const dataValue = { |
| | | StoragePlaceId: e.layer.options.totransferData.StoragePlaceId |
| | | } |
| | | // 基本信息 tabs |
| | | const resultBasic = await mapApi.getSolidWasteBaseInfo(dataValue) |
| | | // 详细信息展示 table |
| | | const resultDetailed = await mapApi.getSolidWasteDetail(dataValue) |
| | | |
| | | // 绑定弹框实例 |
| | | const PublicBounced = window.Vue.extend(publicBounced) |
| | | const instance = new PublicBounced().$mount() |
| | | document.body.appendChild(instance.$el) |
| | | // document.body.removeChild(instance.$el) |
| | | // 通过方法 向绑定弹框传递数据 |
| | | instance.setData(resultBasic.Result.DataInfo, resultDetailed.Result.DataInfo, 'gufei') |
| | | /* flyTo()弹出框平移事件 */ |
| | | this.setPanTo(e.latlng, 200) |
| | | } |
| | | |
| | | // flayTo() 弹框的可滑动事件 |
| | | this.setPanTo = (pos, value) => { |
| | | var position = pos |
| | | position = window.map.latLngToLayerPoint(position) |
| | | position.y += value |
| | | position = window.map.layerPointToLatLng(position) |
| | | window.map.flyTo(position) |
| | | } |
| | | } |