派生自 wuyushui/SewerAndRainNetwork

seatonwan9
2021-05-30 d195225b4e628e541caca0944d54fec027572a06
src/components/LayerController/logic/EnvironmentRisk.js
@@ -1,8 +1,6 @@
/**
 * 环境风险
 * 环境风险统计图
 */
// const EnvironmentRiskIndex = require('@components/base-page/').default
// 请求接口数据
const mapApi = require('../../../api/mapApi').default
// 使用封装方法
@@ -11,10 +9,11 @@
const echarts = require('echarts/lib/echarts')
module.exports = function () {
  // 存放环形图的数组
  let riskLayerGroup = []
  // 环形统计图数组
  let riskLayerGroup = null
  /**
   * 返回marker对象数组
   * 初始化图层数组
   * @param L leaflet对象
   */
  this.init = async (layer, L) => {
@@ -22,25 +21,31 @@
      L: L,
      layer: layer
    })
    layer.addLayer(riskLayerGroup)
  }
  /**
   * 加载图层
   * @returns {Promise<void>}
   */
  this.start = async () => {
    riskLayerGroup = window.layerFactory.L.featureGroup().addTo(window.layerFactory.map)
    const result = await mapApi.getRiskEnterprise()
    if (riskLayerGroup) { // 图层全选时,清理图层数组并重新加载
      riskLayerGroup.remove()
      riskLayerGroup = null
    }
    riskLayerGroup = this.animalService.L.featureGroup().addTo(this.animalService.layer)
    const result = await mapApi.getEnvironmentRisk()
    const features = result.features
    for (var i = 0; i < features.length; i++) {
    for (let 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]], {
      this.animalService.L.marker([coordinates[1], coordinates[0]], {
        icon: this.animalService.L.divIcon({
          className: '',
          iconAnchor: [15, 45],
@@ -48,8 +53,7 @@
          html: '<div style="width: 40px; height: 40px; background-color: rgba(255,255,255,1); position: relative; border-radius: 50%;"></div>'
        })
      }).addTo(riskLayerGroup)
      // this.animalService.layer.addLayer(bgMarker)
      window.layerFactory.L.marker([coordinates[1], coordinates[0]], {
      this.animalService.L.marker([coordinates[1], coordinates[0]], {
        icon: this.animalService.L.divIcon({
          className: '',
          iconAnchor: [30, 60],
@@ -61,35 +65,23 @@
    }
  }
  /**
   * 清除图层
   */
  this.destory = () => {
    if (riskLayerGroup) {
      riskLayerGroup.remove()
      riskLayerGroup = null
    }
  }
  /**
   * tips
   * @param layer
   * @returns {string}
   */
  this.bindTooltip = (layer) => {
  }
  /**
   * 点击弹窗
   * @param e
   */
  this.clickListener = (e) => {
  }
  /**
   * 环形饼图
   * Echarts环形饼图
   * @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
@@ -150,8 +142,5 @@
      }]
    }
    o.setOption(option)
    /* o.on('click', function (params) {
        map.flyTo(L.latLng([params.data.y, params.data.x]), 15)
    }) */
  }
}