From 40f2cc4bdc91f63954c8b2bbd351bc650657affc Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Tue, 12 Nov 2024 14:25:15 +0800
Subject: [PATCH] 配置更改; 图层默认显示调整; 弹窗关闭相关调整;
---
src/hooks/initMap.js | 39 +++++++++++++++++++++++++++++----------
1 files changed, 29 insertions(+), 10 deletions(-)
diff --git a/src/hooks/initMap.js b/src/hooks/initMap.js
index dce2117..09a24c7 100644
--- a/src/hooks/initMap.js
+++ b/src/hooks/initMap.js
@@ -2,7 +2,7 @@
* @Author: shuishen 1109946754@qq.com
* @Date: 2024-10-25 15:09:55
* @LastEditors: shuishen 1109946754@qq.com
- * @LastEditTime: 2024-10-28 19:42:36
+ * @LastEditTime: 2024-11-09 19:55:21
* @FilePath: \bigScreen\src\hooks\initMap.js
* @Description:
*
@@ -10,12 +10,13 @@
*/
let viewer = null
const { VITE_APP_BASE } = import.meta.env
-
import { useMap } from 'store/map'
-import { nextTick } from 'vue'
+import { nextTick, onMounted, onUnmounted } from 'vue'
+import * as turf from '@turf/turf'
+import * as Cesium from 'cesium'
+import 'cesium/Build/Cesium/Widgets/widgets.css'
export function readyViewer () {
- const { appContext } = getCurrentInstance()
const store = useMap()
function initMap () {
@@ -23,21 +24,39 @@
nextTick(() => {
DC.ready({
- baseUrl: `${VITE_APP_BASE}/libs/dc-sdk/resources/`
+ // Cesium: Cesium,
+ baseUrl: `${VITE_APP_BASE}libs/dc-sdk/resources/`,
+ turf,
}).then(() => {
viewer = new DC.Viewer('viewer-container')
- const global = appContext.config.globalProperties
+ window.$viewer = viewer
- global.$viewer = viewer
-
- store.setLoadMap(true)
+ window.$viewer.zoomToPosition(new DC.Position(
+ 115.1048036679409,
+ 27.276835758787513,
+ 4000,
+ 0,
+ -90,
+ 0
+ ), () => {
+ store.setLoadMap(true)
+ })
})
})
}
- initMap()
+ onMounted(() => {
+ initMap()
+ })
+
+ onUnmounted(() => {
+ viewer.destroy()
+ viewer = null
+ delete window.$viewer
+ store.setLoadMap(false)
+ })
return {
--
Gitblit v1.9.3