派生自 wuyushui/SewerAndRainNetwork

seatonwan9
2021-05-31 1da76d05ebba28eeebef8af3832680143d5699c5
src/components/LayerController/logic/Company.js
@@ -1,8 +1,10 @@
/**
 * 固废
 * 企业
 */
// 区分不同类型 使用不同img
const companyImg = '/assets/images/map/company_refining.png'
const companyOil = '/assets/images/map/company_oil.png'
const mapApi = require('../../../api/mapApi').default
const AnimalService = require('../service/AnimalService').default
@@ -13,44 +15,34 @@
   * @param L leaflet对象
   */
  this.init = async (layer, L) => {
    // const SolidWasteIcon = this.SolidWasteIcon()
    this.animalService = new AnimalService({
      L: L,
      layer: layer
    })
    const res = await mapApi.getCompany()
    console.log(res)
    // console.log(res)
    const data = res.Result.DataInfo || {}
    for (let i = 0; i < data.length; i++) {
      // console.log(data[i])
      // 经纬度 位置
      const positionX = data[i].Latitude
      const positionY = data[i].Longitude
      var iconUrl = companyImg
      if (data[i].type) {
        if (data[i].type === 2) {
          iconUrl = companyOil
        }
      }
      const htmls = '<div><img src="' + iconUrl + '"><ul><li>' + data[i].name + '</li><li>' + data[i].name + '</li><li>' + data[i].name + '</li><li>' + data[i].name + '</li><li>' + data[i].name + '</li><li>' + data[i].name + '</li></ul></div>'
      var myIcon = L.divIcon({
        html: htmls,
        className: 'company-bindTooltip',
        iconSize: 16
      })
      const marker = L.marker([positionX, positionY], {
        /* icon: L.icon({
          iconUrl: iconUrl,
          iconSize: [30, 30],
          iconAnchor: [15, 15]
        }), */
        icon: myIcon,
        test: data[i]
      })
      /* const htmls = '<ul><li>' + data[i].name + '</li></ul>'
      marker.bindTooltip(htmls, {
        permanent: true,
        offset: [0, 5],
        direction: 'bottom',
        className: 'company-bindTooltip'
      }) */
      layer.addLayer(marker)
    }
  }
@@ -58,23 +50,27 @@
  * 点位鼠标移入弹框
  * */
  this.bindTooltip = (layer) => {
    console.log(layer)
    //  console.log(layer)
    return '<div class="company-bindTooltip-hover"><h3>污染物产生统计</h3><ul>' +
                '<li>生产设施:30(个)</li>' +
                '<li>治理设施:30(个)</li>' +
            '</ul></div>'// layer.options.test.name
      '<li>生产设施:30(个)</li>' +
      '<li>治理设施:30(个)</li>' +
      '</ul></div>'// layer.options.test.name
  }
  /*
  * 点位点击事件
  *
  * */
  this.clickListener = (e) => {
    // this.animalService.pulseEffect(e.latlng)
    const dataValue = {
      StoragePlaceId: e.layer.options.test.name
    }
    debugger
    console.log(dataValue)
    // return this.PublicBounced.$el
    // console.log(e)
    window.map.setView(e.latlng, 15)
    // if (window.map.getZoom() >= 10) {
    //   window.map.removeLayer(e.layer)
    //   e.layer.remove()
    // } else if (window.map.getZoom() < 10) {
    //   window.map.addLayer(e.layer)
    // }
    // const dataValue = {
    //   StoragePlaceId: e.layer.options.test.name
    // }
  }
}