2026-04-13 10:30:03 +08:00
|
|
|
<template>
|
|
|
|
|
<div class="map_container" id="map-container"></div>
|
|
|
|
|
|
|
|
|
|
<!-- 行政区划 -->
|
2026-04-15 22:41:06 +08:00
|
|
|
<AdministrativeDivision v-if="useStatusStore().appLoadingCompleted" />
|
2026-04-13 10:30:03 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
|
import { onBeforeMount, onMounted } from 'vue';
|
2026-04-13 21:23:24 +08:00
|
|
|
|
2026-04-13 10:30:03 +08:00
|
|
|
import AdministrativeDivision from './AdministrativeDivision.vue';
|
2026-04-14 08:59:05 +08:00
|
|
|
import { useStatusStore } from '@/stores/useStatusStore';
|
2026-04-13 10:30:03 +08:00
|
|
|
import { useLoadingInformationStore } from '@/stores/useLoadingInformation';
|
2026-04-13 21:23:24 +08:00
|
|
|
|
|
|
|
|
import { CesiumUtilsSingleton } from '@/utils/cesium/CesiumUtils';
|
2026-04-13 20:55:32 +08:00
|
|
|
import { xiAn } from '@/assets';
|
2026-04-13 21:23:24 +08:00
|
|
|
import { Color } from 'cesium';
|
|
|
|
|
import type { GeoJsonFileType } from '@/types/cesium/GeoJsonFileType';
|
|
|
|
|
import config from '@/config/config.json';
|
|
|
|
|
import { useMap } from '@/hooks/map/useMap';
|
2026-04-13 10:30:03 +08:00
|
|
|
|
|
|
|
|
onBeforeMount(() => {
|
|
|
|
|
// 初始化为false
|
2026-04-15 22:41:06 +08:00
|
|
|
useStatusStore().appLoadingCompleted = false;
|
2026-04-13 10:30:03 +08:00
|
|
|
|
|
|
|
|
// 重置状态
|
|
|
|
|
useLoadingInformationStore().resetStatue();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
2026-04-13 21:23:24 +08:00
|
|
|
// 初始化Cesium
|
2026-04-13 10:30:03 +08:00
|
|
|
await CesiumUtilsSingleton.initCesiumViewer({
|
|
|
|
|
containerId: 'map-container',
|
|
|
|
|
mark: {
|
|
|
|
|
include: true,
|
2026-04-13 20:55:32 +08:00
|
|
|
geoJson: xiAn as GeoJsonFileType,
|
2026-04-13 10:30:03 +08:00
|
|
|
color: Color.BLACK.withAlpha(0.8),
|
|
|
|
|
border: {
|
|
|
|
|
width: 3,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-13 21:23:24 +08:00
|
|
|
// 设置状态
|
2026-04-15 22:41:06 +08:00
|
|
|
useStatusStore().appLoadingCompleted = true;
|
2026-04-13 10:30:03 +08:00
|
|
|
|
|
|
|
|
// 注册全局点击监听器
|
2026-04-13 21:23:24 +08:00
|
|
|
useMap().registerAndClickOnTheListener();
|
2026-04-13 10:30:03 +08:00
|
|
|
|
|
|
|
|
// 注册全局滚轮监听器
|
2026-04-13 21:23:24 +08:00
|
|
|
useMap().registerAScrollListener();
|
2026-04-13 10:30:03 +08:00
|
|
|
|
|
|
|
|
// 当行政区超出页面时,自动拉回视角
|
2026-04-13 21:23:24 +08:00
|
|
|
useMap().automaticallyAdjustThePerspective();
|
2026-04-13 10:30:03 +08:00
|
|
|
|
2026-04-13 21:23:24 +08:00
|
|
|
// 禁止事件
|
|
|
|
|
useMap().prohibitedEvents();
|
2026-04-13 10:30:03 +08:00
|
|
|
|
|
|
|
|
// 默认视角
|
|
|
|
|
CesiumUtilsSingleton.viewToTarget(
|
|
|
|
|
config.defaultPosition as [number, number, number]
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
.map_container {
|
|
|
|
|
width: 100vw;
|
|
|
|
|
height: 100vh;
|
|
|
|
|
margin: 0;
|
|
|
|
|
padding: 0;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
position: absolute;
|
|
|
|
|
top: 0;
|
|
|
|
|
left: 0;
|
|
|
|
|
}
|
|
|
|
|
</style>
|