派生自 wuyushui/SewerAndRainNetwork

chenzeping
2021-04-02 cb4ce544a38a4720b88946949b3258705d5ae2da
src/components/helpers/BasemapHelper.js
@@ -1,5 +1,6 @@
/* eslint-disable no-debugger */
import AjaxUtils from '@/utils/AjaxUtils'
import * as utils from '../../utils/utils'
/**
 * 底图管理助手,负责底图创建及开关
@@ -53,23 +54,15 @@
     */
    showBasemap = (code, showAnnotation, isHideOthers = true) => {
      const basemap = this.basemapMap.get(code)
      if (isHideOthers) {
        this.basemapLayerGroup.clearLayers()
      }
      setTimeout(() => {
        // const layer = this.basemapLayerGroup.hasLayer(basemap.layer)
        // if (!layer) {
        this.basemapLayerGroup.addLayer(basemap.layer)
        // }
        if (showAnnotation) {
          // if()
          this.basemapLayerGroup.addLayer(basemap.annotation)
        } else {
          this.basemapLayerGroup.removeLayer(basemap.annotation)
        }
      }, 300)
      this.basemapLayerGroup.addLayer(basemap.layer)
      if (showAnnotation) {
        this.basemapLayerGroup.addLayer(basemap.annotation)
      } else {
        this.basemapLayerGroup.removeLayer(basemap.annotation)
      }
    }
    /**
@@ -87,8 +80,10 @@
      const internetBasemaps = config.mapConfig.InternetBaseMaps
      for (let i = 0, len = internetBasemaps.length; i < len; ++i) {
        const basemapConfig = internetBasemaps[i]
        const basemapLayer = this.L.tileLayer(basemapConfig.map.url, basemapConfig.map.option)
        const basemapAnnotationLayer = this.L.tileLayer(basemapConfig.annotation.url, basemapConfig.annotation.option)
        const mapToken = utils.getRandomTDTToken()
        const mapUrl = utils.changeURLArg(basemapConfig.map.url, 'tk', mapToken)
        const basemapLayer = this.L.tileLayer(mapUrl, basemapConfig.map.option)
        const basemapAnnotationLayer = this.L.tileLayer(mapUrl, basemapConfig.annotation.option)
        const basemap = {
          code: basemapConfig.code,