智慧园区前端大屏
linwe
2024-11-07 05affc703e81728cc58cc89c1815407ad4997dfe
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-11-04 18:08:12
 * @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 () {
@@ -28,10 +27,9 @@
        viewer = new DC.Viewer('viewer-container')
        const global = appContext.config.globalProperties
        global.$viewer = viewer
        window.$viewer = viewer
        global.$viewer.zoomToPosition(new DC.Position(
        window.$viewer.zoomToPosition(new DC.Position(
          115.1048036679409,
          27.276835758787513,
          4000,
@@ -39,15 +37,22 @@
          -90,
          0
        ), () => {
          store.setLoadMap(true)
        })
      })
    })
  }
  initMap()
  onMounted(() => {
    initMap()
  })
  onUnmounted(() => {
    viewer.destroy()
    viewer = null
    delete window.$viewer
    store.setLoadMap(false)
  })
  return {