From ecdffd165cf73c0e3c051c69d1dfdc71ba9331c8 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Tue, 26 Nov 2024 01:18:01 +0800
Subject: [PATCH] 突发事件模拟调整
---
src/hooks/initMap.js | 48 ++++++++++++++++++++++++++++++++++--------------
1 files changed, 34 insertions(+), 14 deletions(-)
diff --git a/src/hooks/initMap.js b/src/hooks/initMap.js
index 5569c85..44a9d28 100644
--- a/src/hooks/initMap.js
+++ b/src/hooks/initMap.js
@@ -2,39 +2,46 @@
* @Author: shuishen 1109946754@qq.com
* @Date: 2024-10-25 15:09:55
* @LastEditors: shuishen 1109946754@qq.com
- * @LastEditTime: 2024-11-07 16:15:48
+ * @LastEditTime: 2024-11-25 16:43:43
* @FilePath: \bigScreen\src\hooks\initMap.js
* @Description:
*
* Copyright (c) 2024 by shuishen, All Rights Reserved.
*/
-let viewer = null
+window.$viewer = null
+window.$Cesium = null
+window.$turf = 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 Cesium = DC.getLib('Cesium')
const store = useMap()
function initMap () {
- if (viewer) return
+ if (window.$viewer) return
nextTick(() => {
DC.ready({
- baseUrl: `${VITE_APP_BASE}libs/dc-sdk/resources/`
+ // Cesium: Cesium,
+ baseUrl: `${VITE_APP_BASE}libs/dc-sdk/resources/`,
+ turf,
}).then(() => {
+ window.$Cesium = DC.getLib('Cesium')
+ window.$turf = DC.getLib('turf')
- viewer = new DC.Viewer('viewer-container')
-
- window.$viewer = viewer
+ window.$viewer = new DC.Viewer('viewer-container')
+ window.$viewer.locationBar.enable = true
window.$viewer.zoomToPosition(new DC.Position(
- 115.1048036679409,
- 27.276835758787513,
- 4000,
+ 115.1021,
+ 27.2360,
+ 5000,
0,
- -90,
+ -45,
0
), () => {
store.setLoadMap(true)
@@ -43,7 +50,20 @@
})
}
- initMap()
+ onMounted(() => {
+ initMap()
+ })
+
+ onUnmounted(() => {
+ window.$viewer.destroy()
+ window.$viewer = null
+ window.$Cesium = null
+ window.$turf = null
+ delete window.$viewer
+ delete window.$Cesium
+ delete window.$turf
+ store.setLoadMap(false)
+ })
return {
--
Gitblit v1.9.3