63 lines
2.0 KiB
JavaScript
Raw Normal View History

2025-11-18 19:19:30 +08:00
import { getBusinessBaseMapDDT, getBusinessBaseMapSI, test } from '@/views/cockpit/api/commonHttp.js'
2025-11-18 17:53:04 +08:00
// 当前页面的最基础地图服务
// 主要是加载地图底图
export const useMapBase = (mapStore) => {
2025-11-18 19:19:30 +08:00
const loadBusinessBaseMapDDT = async () => {
2025-11-18 17:53:04 +08:00
const layerService = mapStore.services().layer
2025-11-18 19:19:30 +08:00
const res = await getBusinessBaseMapDDT()
2025-11-18 17:53:04 +08:00
const data = [...res]
mapStore.baseMapGroups = data
for (const item of data) {
const layers = mapStore.getBaseMapLayersForGroup(item.Attribute?.rid || item.Rid)
for (const layerConfig of layers) {
const layer = {
id: layerConfig.id,
type: layerConfig.type,
url: layerConfig.url,
meta: layerConfig.meta,
2025-11-18 19:19:30 +08:00
options: {
parameters: {
srs: 'EPSG:3857',
transparent: true,
}
}
2025-11-18 17:53:04 +08:00
}
await layerService.addLayer(layer)
}
}
2025-11-18 19:19:30 +08:00
}
2025-11-18 17:53:04 +08:00
2025-11-18 19:19:30 +08:00
const loadBusinessBaseMapLayerSI = async () => {
const layerService = mapStore.services().layer
const res = await getBusinessBaseMapSI()
const data = [...res]
mapStore.baseMapGroups = data
for (const item of data) {
const layers = mapStore.getBaseMapLayersForGroup(item.Attribute?.rid || item.Rid)
for (const layerConfig of layers) {
const layer = {
id: layerConfig.id,
type: layerConfig.type,
url: layerConfig.url,
meta: layerConfig.meta,
}
await layerService.addLayer(layer)
}
}
2025-11-18 17:53:04 +08:00
}
const loadBaseData = () => {
setTimeout(() => {
2025-11-18 19:19:30 +08:00
// loadBusinessBaseMapDDT()
// test()
loadBusinessBaseMapLayerSI()
2025-11-18 17:53:04 +08:00
}, 0)
}
return {
loadBaseData
}
}