派生自 wuyushui/SewerAndRainNetwork

chenyabin
2021-04-19 c7a549da66df42d4ec5c78ddf2cc138772616941
src/components/LayerController/service/LayerFactory.js
@@ -2,7 +2,7 @@
import BusiLayerService from './BusiLayerService'
import WmsLayerService from './WmsLayerService'
import EventLayerService from './EventLayerService'
import { clone } from '../../../utils/utils'
class LayerFactory {
  constructor (options) {
    this.L = options.L
@@ -112,15 +112,37 @@
  hide (config) {
    var layer = this.layers[config.code]
    layer && this.map.removeLayer(layer)
    this.load(config)
    // this.load(config)
  }
  toggle (code) {
  }
  flyByLayerId (code, id) {
    const layer = this.layers[code]
  /**
   *
   * 根据传的 feature对象定位
   * @param code
   * @param feature
   */
  flyByFeature (feature, code) {
    const type = feature.geometry.type
    var point = []
    switch (type) {
      case 'Point':
        point = clone(feature.geometry.coordinates)
        break
      case 'MultiLineString':
        var coordinates = feature.geometry.coordinates
        point = clone(coordinates[parseInt(coordinates.length / 2)][0])
        break
    }
    window.map.flyTo(point.reverse(), 15)
    code && this.openPopup(code, feature.id)
  }
  openPopup (layerId, id) {
    const layer = this.layers[layerId]
    if (layer.eachLayer) {
      layer.eachLayer(function (layer) {