派生自 wuyushui/SewerAndRainNetwork

wangrui
2020-12-19 7cc388b27687343c0aa237cfdabf638d83dc2a5d
src/components/helpers/BasemapHelper.js
@@ -1,28 +1,37 @@
import AjaxUtils from '@/utils/AjaxUtils'
import CommonLayerLoad from '../mapmodules/CommonLayerLoad'
/**
 * 底图管理助手,负责底图创建及开关
 */
function BasemapHelper(map, L) {
    this.map = map
    this.L = L
    this.basemapList = []
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 初始化完成后,默认显示的图层
     */
    this.initBasemap = (map, defBasemapName) => {
        console.log(map, defBasemapName)
        // todo 创建完以后,把图层都放到basemapList对象保存起来,方便其他接口调用
    initBasemap = (mapConfig, isIntranet) => {
        if(isIntranet) {
            this._getToken(mapConfig);
        }else {
            //
        }
        return null
        return this.basemapMap
    }
    /**
     * 获取所有的底图列表
     * @returns {null} 结构:[{名称, 图层引用}]
     */
    this.getBasemapList = (map) => {
    getBasemapList = (map) => {
        console.log(map)
        return null
    }
@@ -32,7 +41,7 @@
     * @param map 结构:[{名称, 图层引用}]
     * @param name 名称
     */
    this.getBasemap = (map, name) => {
    getBasemap = (map, name) => {
        console.log(map, name)
    }
@@ -42,7 +51,7 @@
     * @param layer 待显示图层引用
     * @param isHideOthers 是否先关闭其他图层,默认是true
     */
    this.showBasemap = (map, layer, isHideOthers) => {
    showBasemap = (map, layer, isHideOthers) => {
        console.log(map, layer, isHideOthers)
    }
@@ -51,9 +60,24 @@
     * @param map 地图对象
     * @param layer 待关闭图层引用
     */
    this.hideBasemap = (map, 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