派生自 wuyushui/SewerAndRainNetwork

徐旺旺
2021-05-18 755baaf11dd4e5c8eb7a5c2aa0ea23732fe47c85
src/components/helpers/MapManager.js
@@ -1,6 +1,6 @@
import AjaxUtils from '../../utils/AjaxUtils'
import { WMS_URL } from '../../conf/Constants'
import { openPopup } from './LocateHelper'
import { highlight, openPropsPopup } from './LocateHelper'
class MapManager {
  constructor () {
@@ -27,17 +27,22 @@
    this.map.on('click', (e) => {
      // console.log(e)
      this.clearHighlight()
      this.loadWfsDatas(e.latlng)
      this.loadWfsDatas(e.latlng).then((res) => {
        console.log(res)
        highlight(res.features)
        openPropsPopup(e.latlng, res.features)
      })
    })
  }
  loadWfsDatas (latlng) {
  loadWfsDatas (latlng, params) {
    return new Promise((resolve, reject) => {
    const size = this.map.getSize()
    var point = this.map.latLngToContainerPoint(latlng, this.map.getZoom())
    const wmsLayerService = window.layerFactory.wmsLayerService
    const layers = wmsLayerService.wmsLayerList.getLayers()
    // const filters = wmsLayerService.wmsLayerList.getFilters()
    const params = Object.assign({
      const wmsParams = Object.assign({
      LAYERS: layers,
      QUERY_LAYERS: layers,
      WIDTH: size.x,
@@ -45,9 +50,10 @@
      X: Math.round(point.x),
      Y: Math.round(point.y),
      BBOX: this.map.getBounds().toBBoxString()
    }, this.defaultWmsParams)
    AjaxUtils.get4JsonDataByUrl(WMS_URL, params, (res) => {
      openPopup(latlng, res.data.features)
      }, this.defaultWmsParams, params)
      AjaxUtils.get4JsonDataByUrl(WMS_URL, wmsParams, (res) => {
        resolve(res.data)
      })
    })
  }