/** * 环境风险 */ // const EnvironmentRiskIndex = require('@components/base-page/').default // 请求接口数据 const mapApi = require('../../../api/mapApi').default // 使用封装方法 const AnimalService = require('../service/AnimalService').default // 引入echarts基本组件 const echarts = require('echarts/lib/echarts') module.exports = function () { // 存放环形图的数组 let riskLayerGroup = [] /** * 返回marker对象数组 * @param L leaflet对象 */ this.init = async (layer, L) => { this.animalService = new AnimalService({ L: L, layer: layer }) layer.addLayer(riskLayerGroup) } this.start = async () => { riskLayerGroup = window.layerFactory.L.featureGroup().addTo(window.layerFactory.map) const result = await mapApi.getRiskEnterprise() const features = result.features for (var i = 0; i < features.length; i++) { const feature = features[i] const geometry = feature.geometry const properties = feature.properties const qyId = properties.QY_ID // const qyJc = properties.QY_JC const distract = properties.DISTRACT const coordinates = geometry.coordinates if (distract !== '长江沿线') { continue } window.layerFactory.L.marker([coordinates[1], coordinates[0]], { icon: this.animalService.L.divIcon({ className: '', iconAnchor: [15, 45], iconSize: [40, 40], html: '
' }) }).addTo(riskLayerGroup) // this.animalService.layer.addLayer(bgMarker) window.layerFactory.L.marker([coordinates[1], coordinates[0]], { icon: this.animalService.L.divIcon({ className: '', iconAnchor: [30, 60], iconSize: [70, 70], html: '' }) }).addTo(riskLayerGroup) chartRender(properties) } } this.destory = () => { if (riskLayerGroup) { riskLayerGroup.remove() } } /** * tips * @param layer * @returns {string} */ this.bindTooltip = (layer) => { } /** * 点击弹窗 * @param e */ this.clickListener = (e) => { } /** * 环形饼图 * @param properties */ function chartRender (properties) { const qyId = properties.QY_ID const qyjc = properties.QY_JC // const qyQc = properties.QY_QC const num = properties.QY_NUM const oneLevel = properties.QY_ONELEVEL const twoLevel = properties.QY_TWOLEVEL const threeLevel = properties.QY_THREELEVEL const o = echarts.init(document.getElementById('qy_id_' + qyId)) const option = { tooltip: { trigger: 'item', formatter: function (e) { return '