派生自 wuyushui/SewerAndRainNetwork

徐旺旺
2021-04-21 b781d8f13a5b6ce20cfad7ec6c2d0a72013a8764
修改比例尺的BUG
3个文件已修改
115 ■■■■ 已修改文件
src/components/LayerController/service/LayerFactory.js 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/LayerController/service/WfsLayerService.js 84 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/conf/layers/LayerHbss.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/LayerController/service/LayerFactory.js
@@ -32,7 +32,13 @@
  initMinZoom (config) {
    const minZoom = parseInt(config.minZoom)
    if (minZoom) {
      this.minZoomLayers[minZoom] = config
      var configs = this.minZoomLayers[minZoom]
      if (configs) {
        configs[configs.length] = config
      } else {
        configs = [config]
      }
      this.minZoomLayers[minZoom] = configs
    }
  }
@@ -101,20 +107,23 @@
     * @param layerConfig
     */
  initEvent (layerConfig) {
    // this.map.on('zoomend ', () => this.toggleByZoom())
    this.map.on('zoomend ', () => this.toggleByZoom())
  }
  toggleByZoom () {
    const zoom = this.map.getZoom()
    for (var k in this.minZoomLayers) {
      const config = this.minZoomLayers[k]
      const checked = config.checked
      console.log(zoom)
      console.log(k)
      if (checked && zoom > k) {
        this.show(config)
      } else if (checked && zoom < k) {
        this.hide(config)
      const configs = this.minZoomLayers[k]
      for (var j in configs) {
        const config = configs[j]
        const checked = config.checked
        console.log(zoom)
        console.log(k)
        if (checked && zoom > k) {
          this.show(config)
        } else if (checked && zoom < k) {
          this.hide(config)
        }
      }
    }
  }
src/components/LayerController/service/WfsLayerService.js
@@ -35,48 +35,50 @@
  }
  draw (features) {
    const icon = this.config.icon
    const styles = this.config.styles
    Object.assign(STYLES, styles)
    const geojsonLayer = this.L.geoJSON(features, {
      style: function (feature) {
        return {
          fill: STYLES.FILL,
          weight: STYLES.WEIGHT,
          fillColor: STYLES.FILL_COLOR,
          color: STYLES.COLOR,
          fillOpacity: STYLES.FILL_OPACITY,
          opacity: STYLES.OPACITY
          // dashArray: STYLES.DASH_ARRAY,
          // dashSpeed: STYLES.DASH_SPPED
        }
      },
      pointToLayer: (geoJsonPoint, latlng) => {
        return this.L.canvasMarker(latlng,
          {
            img: {
              // url: 'assets/images/map/marker-icon.png',
              url: '/assets/images/map/' + icon,
              size: STYLES.ICON_SIZE
            }
    if (features && features.length > 0) {
      const icon = this.config.icon
      const styles = this.config.styles
      Object.assign(STYLES, styles)
      const geojsonLayer = this.L.geoJSON(features, {
        style: function (feature) {
          return {
            fill: STYLES.FILL,
            weight: STYLES.WEIGHT,
            fillColor: STYLES.FILL_COLOR,
            color: STYLES.COLOR,
            fillOpacity: STYLES.FILL_OPACITY,
            opacity: STYLES.OPACITY
            // dashArray: STYLES.DASH_ARRAY,
            // dashSpeed: STYLES.DASH_SPPED
          }
        },
        pointToLayer: (geoJsonPoint, latlng) => {
          return this.L.canvasMarker(latlng,
            {
              img: {
                // url: 'assets/images/map/marker-icon.png',
                url: '/assets/images/map/' + icon,
                size: STYLES.ICON_SIZE
              }
            })
        },
        onEachFeature: (feature, layer) => {
          layer.bindPopup((layer) => {
            this.popupComp.setDatas(layer)
            this.popupComp.setShow()
            return this.popupComp.$el
          }, {
            className: 's-map-popup',
            minWidth: 300,
            closeButton: false,
            autoClose: false
          })
      },
      onEachFeature: (feature, layer) => {
        layer.bindPopup((layer) => {
          this.popupComp.setDatas(layer)
          this.popupComp.setShow()
          return this.popupComp.$el
        }, {
          className: 's-map-popup',
          minWidth: 300,
          closeButton: false,
          autoClose: false
        })
          .bindTooltip((layer) => this.tooltipListener(layer), { direction: 'bottom', offset: [0, 15], sticky: true })
          .on('mouseover', (e) => this.mouseOverListener(e, layer)).on('mouseout', (e) => this.mouseOutListener(e, layer))
      }
    }).addTo(this.layer)
    setZIndex(geojsonLayer)
            .bindTooltip((layer) => this.tooltipListener(layer), { direction: 'bottom', offset: [0, 15], sticky: true })
            .on('mouseover', (e) => this.mouseOverListener(e, layer)).on('mouseout', (e) => this.mouseOutListener(e, layer))
        }
      }).addTo(this.layer)
      setZIndex(geojsonLayer)
    }
  }
  mouseOverListener (e, layer) {
src/conf/layers/LayerHbss.js
@@ -12,7 +12,7 @@
      code: 'yj',
      name: '窨井',
      sname: '窨井',
      checked: true,
      checked: false,
      minZoom: 16,
      wfs: WFS_URL + '?TYPENAME=窨井',
      icon: 'sewers/窨井.png'