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
|