New file |
| | |
| | | /** |
| | | * 污染源 |
| | | */ |
| | | // 信息组件 |
| | | // const SourcePollutionIndex = require('../../base-page/RiskSource/RiskSourceIndex.vue').default |
| | | // 使用封装方法 |
| | | const AnimalService = require('../service/AnimalService').default |
| | | // 请求接口数据 |
| | | const mapApi = require('../../../api/mapApi').default |
| | | // 公共方法 panTo() 引用 |
| | | // const { setPanTo } = require('../../../utils/utils') |
| | | |
| | | module.exports = function () { |
| | | /** |
| | | * 初始化并加载图层 |
| | | * @param L leaflet对象 |
| | | */ |
| | | this.init = async (layer, L) => { |
| | | this.animalService = new AnimalService({ |
| | | L: L, |
| | | layer: layer |
| | | }) |
| | | const result = await mapApi.getEnvironmentRiskPoint() |
| | | const data = result[0] |
| | | for (let i = 0; i < data.length; i++) { |
| | | const postion = [data[i].Latitude, data[i].Longitude] // 坐标 |
| | | const iconUrl = this.sourcePollutionIconUrl(1) // 治理设施图标 |
| | | const marker = L.marker(postion, { |
| | | totransferData: data[i], |
| | | icon: L.icon({ |
| | | iconUrl: iconUrl, |
| | | iconSize: [20, 20], |
| | | iconAnchor: [10, 10] |
| | | }) |
| | | }) |
| | | layer.addLayer(marker) |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 治理设施图标配置 |
| | | * @param t |
| | | * @returns {string} |
| | | */ |
| | | this.sourcePollutionIconUrl = (t) => { |
| | | let iconUrl = null |
| | | switch (t) { |
| | | case 1: |
| | | iconUrl = '' |
| | | break |
| | | case 2: |
| | | iconUrl = '' |
| | | break |
| | | default: |
| | | iconUrl = '' |
| | | break |
| | | } |
| | | return iconUrl |
| | | } |
| | | } |