From a3eb3f7fd0889c3eed7ea5f5c812246779efa53c Mon Sep 17 00:00:00 2001
From: linwe <872216996@qq.com>
Date: Thu, 07 Nov 2024 20:25:13 +0800
Subject: [PATCH] 企业详情

---
 src/hooks/initMap.js |   48 ++++++++++++++++++++++++------------------------
 1 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/src/hooks/initMap.js b/src/hooks/initMap.js
index 872ce88..3d10d98 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-30 18:09:34
+ * @LastEditTime: 2024-11-07 19:24:27
  * @FilePath: \bigScreen\src\hooks\initMap.js
  * @Description: 
  * 
@@ -11,11 +11,10 @@
 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'
 
 export function readyViewer () {
   const Cesium = DC.getLib('Cesium')
-  const { appContext } = getCurrentInstance()
   const store = useMap()
 
   function initMap () {
@@ -23,36 +22,37 @@
 
     nextTick(() => {
       DC.ready({
-        baseUrl: `${VITE_APP_BASE}/libs/dc-sdk/resources/`
+        baseUrl: `${VITE_APP_BASE}libs/dc-sdk/resources/`
       }).then(() => {
 
         viewer = new DC.Viewer('viewer-container')
 
-        const global = appContext.config.globalProperties
+        window.$viewer = viewer
 
-        global.$viewer = viewer
-
-        store.setLoadMap(true)
-
-        // let layer = new DC.HtmlLayer('layer')
-        // viewer.addLayer(layer)
-        // let divIcon = new DC.DivIcon(
-        //   new DC.Position(125, 25),
-        //   `<div class="public-map-popup">
-        //     <div class="marsBlueGradientPnl">
-        //       <div>指挥室</div>
-        //     </div>
-        //   </div>`
-        // )
-
-        // divIcon.setStyle({
-        // })
-        // layer.addOverlay(divIcon)
+        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