2026-04-08 14:18:03 +08:00
|
|
|
<template>
|
|
|
|
|
<div class="map_container" id="map-container"></div>
|
2026-04-09 10:26:30 +08:00
|
|
|
|
|
|
|
|
<!-- 行政区划 -->
|
2026-04-11 10:09:40 +08:00
|
|
|
<AdministrativeDivision v-if="useViewerStore().getViewerLoadingCompleted()" />
|
2026-04-08 14:18:03 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2026-04-11 10:09:40 +08:00
|
|
|
import { onBeforeMount, onMounted } from 'vue';
|
2026-04-08 14:18:03 +08:00
|
|
|
import config from '@/config/config.json';
|
2026-04-08 18:17:54 +08:00
|
|
|
import { CesiumUtilsSingleton } from '@/utils/cesium/CesiumUtils';
|
2026-04-09 10:26:30 +08:00
|
|
|
import AdministrativeDivision from './AdministrativeDivision.vue';
|
2026-04-11 10:09:40 +08:00
|
|
|
import { useViewerStore } from '@/stores/useViewerStore';
|
2026-04-08 14:18:03 +08:00
|
|
|
|
2026-04-11 10:09:40 +08:00
|
|
|
onBeforeMount(() => {
|
|
|
|
|
// 初始化为false
|
|
|
|
|
useViewerStore().setViewerLoadingCompleted(false)
|
|
|
|
|
|
|
|
|
|
// 清除viewer相关资源
|
|
|
|
|
if (CesiumUtilsSingleton.getViewer()) {
|
|
|
|
|
CesiumUtilsSingleton.clearAllResources('all')
|
|
|
|
|
}
|
|
|
|
|
})
|
2026-04-08 14:18:03 +08:00
|
|
|
|
|
|
|
|
onMounted(() => {
|
2026-04-08 18:17:54 +08:00
|
|
|
CesiumUtilsSingleton.initCesiumViewer({
|
|
|
|
|
containerId: 'map-container'
|
2026-04-08 14:18:03 +08:00
|
|
|
})
|
2026-04-11 10:09:40 +08:00
|
|
|
|
|
|
|
|
// 更新完成状态
|
|
|
|
|
useViewerStore().setViewerLoadingCompleted(true)
|
2026-04-08 18:17:54 +08:00
|
|
|
CesiumUtilsSingleton.viewToTarget(config.defaultPosition as [number, number, number]);
|
2026-04-08 14:18:03 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
.map_container {
|
|
|
|
|
width: 100vw;
|
|
|
|
|
height: 100vh;
|
|
|
|
|
margin: 0;
|
|
|
|
|
padding: 0;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
position: absolute;
|
|
|
|
|
top: 0;
|
|
|
|
|
left: 0;
|
|
|
|
|
}
|
|
|
|
|
</style>
|