派生自 wuyushui/SewerAndRainNetwork

chenzeping
2021-04-12 68d9f6b85690aa6402a69a1bc748be7129f39ed1
src/components/helpers/BasemapHelper.js
@@ -1,6 +1,6 @@
/* eslint-disable no-debugger */
import AjaxUtils from '@/utils/AjaxUtils'
// import * as utils from '../../utils/utils'
/**
 * 底图管理助手,负责底图创建及开关
 */
@@ -19,7 +19,7 @@
     * @param map
     * @param defBasemapName 初始化完成后,默认显示的图层
     */
    initBasemap = (config, isIntranet) => {
    initBasemap =async (config, isIntranet) => {
      if (isIntranet) { // 内网
        this._getToken(config) // 获取token后,并按配置加载地图
      } else { // 外网
@@ -53,23 +53,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)
      }
    }
    /**
@@ -109,11 +101,10 @@
    // 内网地图创建部分
    // 获取内网地图token,并加载到地图中
    _getToken = (config) => {
    _getToken = async (config) => {
      const params = config.TokenConfig
      AjaxUtils.GetDataAsynByUrl(params.url, params.option, (token) => {
        this._showTDT(token, config)
      })
      const token = await AjaxUtils.GetDataAsynByUrl(params.url, params.option)
      this._showTDT(token, config)
    }
    // 内网地图加载,并加载到地图
@@ -121,8 +112,8 @@
      const intranetBasemaps = config.mapConfig.IntranetBaseMaps
      for (let i = 0, len = intranetBasemaps.length; i < len; ++i) {
        const basemapConfig = intranetBasemaps[i]
        const basemapLayer = this.L.tileLayer(basemapConfig.map.url, basemapConfig.map.option)
        const basemapAnnotationLayer = this.L.tileLayer(basemapConfig.annotation.url, basemapConfig.annotation.option)
        const basemapLayer = this.L.tileLayer(basemapConfig.map.url + '&token=' + token, basemapConfig.map.option)
        const basemapAnnotationLayer = this.L.tileLayer(basemapConfig.annotation.url + '&token=' + token, basemapConfig.annotation.option)
        const basemap = {
          code: basemapConfig.code,