派生自 wuyushui/SewerAndRainNetwork

ba
wangrui
2020-12-19 2681b362f5e4445c65083c5210e2f2730fc4b684
ba
1个文件已修改
29 ■■■■■ 已修改文件
src/components/helpers/BasemapHelper.js 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/helpers/BasemapHelper.js
@@ -18,7 +18,6 @@
     * @param defBasemapName 初始化完成后,默认显示的图层
     */
    initBasemap = (mapConfig, isIntranet) => {
        debugger
        if(isIntranet) {
            this._getToken(mapConfig); // 获取token,并按配置加载地图
        }else {
@@ -32,18 +31,17 @@
     * 获取所有的底图列表
     * @returns {null} 结构:[{名称, 图层引用}]
     */
    getBasemapList = (map) => {
        console.log(map)
        return null
    getBasemapList = () => {
        return this.basemapList
    }
    /**
     * 通过名称获取底图对象
     * @param map 结构:[{名称, 图层引用}]
     * @param name 名称
     * @param code 名称
     */
    getBasemap = (map, name) => {
        console.log(map, name)
    getBasemap = (map, code) => {
        return this.basemapMap.get(code)
    }
    /**
@@ -52,8 +50,15 @@
     * @param layer 待显示图层引用
     * @param isHideOthers 是否先关闭其他图层,默认是true
     */
    showBasemap = (map, layer, isHideOthers) => {
        console.log(map, layer, isHideOthers)
    showBasemap = (map, code, isHideOthers = true) => {
        let basemap = this.basemapMap.get(code)
        if(isHideOthers) {
            for(let i = 0, len = this.basemapList.length; i < len; ++i){
                map.removeLayer(this.basemapList[i])
            }
        }
        map.addLayer(basemap.layer)
        map.addLayer(basemap.annotation)
    }
    /**
@@ -61,8 +66,10 @@
     * @param map 地图对象
     * @param layer 待关闭图层引用
     */
    hideBasemap = (map, layer) => {
        console.log(map, layer)
    hideBasemap = (map, code) => {
        let basemap = this.basemapMap.get(code)
        map.removeLayer(basemap.layer)
        map.removeLayer(basemap.annotation)
    }
    // 公网创建地图部分