派生自 wuyushui/SewerAndRainNetwork

wangrui
2020-12-19 44280203af25006efc4b8939b4fc01477041e9b8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import AjaxUtils from '@/utils/AjaxUtils'
import CommonLayerLoad from '../mapmodules/CommonLayerLoad'
/**
 * 底图管理助手,负责底图创建及开关
 */
class BasemapHelper{
    constructor(map, L) {
        this.map = map
        this.L = L
        this.basemapList = []
        this.basemapMap = new Map()
        this.basemapLayerGroup = L.layerGroup().addTo(map)
    }
 
    /**
     * 该方法负责各种底图加载到地图上
     * @param map
     * @param defBasemapName 初始化完成后,默认显示的图层
     */
    initBasemap = (mapConfig, isIntranet) => {
        if(isIntranet) {
            this._getToken(mapConfig);
        }else {
            //
        }
 
        return this.basemapMap
    }
 
    /**
     * 获取所有的底图列表
     * @returns {null} 结构:[{名称, 图层引用}]
     */
    getBasemapList = (map) => {
        console.log(map)
        return null
    }
 
    /**
     * 通过名称获取底图对象
     * @param map 结构:[{名称, 图层引用}]
     * @param name 名称
     */
    getBasemap = (map, name) => {
        console.log(map, name)
    }
 
    /**
     * 显示某个图层
     * @param map 地图对象
     * @param layer 待显示图层引用
     * @param isHideOthers 是否先关闭其他图层,默认是true
     */
    showBasemap = (map, layer, isHideOthers) => {
        console.log(map, layer, isHideOthers)
    }
 
    /**
     * 隐藏某个图层
     * @param map 地图对象
     * @param layer 待关闭图层引用
     */
    hideBasemap = (map, layer) => {
        console.log(map, layer)
    }
 
    _getToken = (mapConfig) => {
        let params = mapConfig.TokenConfig
        AjaxUtils.GetDataAsynByUrl(params.url, params.option, (token) => {
            this._showTDT(token)
        })
    }
 
    _showTDT = (token) => {
        let commonLayerLoad = new CommonLayerLoad()
        const imgMapm = commonLayerLoad.loadIntranetImgMap(token)
        const imgMapa = commonLayerLoad.loadIntranetImgMapCia(token)
        this.basemapLayerGroup.addLayer(imgMapm)
        this.basemapLayerGroup.addLayer(imgMapa)
    }
}
 
export default BasemapHelper