智慧园区前端大屏
shuishen
2024-12-18 9a37c5e1b2190c3f6ec71483923922189091dd52
src/hooks/initMap.js
@@ -1,45 +0,0 @@
/*
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2024-10-25 15:09:55
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2024-10-28 19:42:36
 * @FilePath: \bigScreen\src\hooks\initMap.js
 * @Description:
 *
 * Copyright (c) 2024 by shuishen, All Rights Reserved.
 */
let viewer = null
const { VITE_APP_BASE } = import.meta.env
import { useMap } from 'store/map'
import { nextTick } from 'vue'
export function readyViewer () {
  const { appContext } = getCurrentInstance()
  const store = useMap()
  function initMap () {
    if (viewer) return
    nextTick(() => {
      DC.ready({
        baseUrl: `${VITE_APP_BASE}/libs/dc-sdk/resources/`
      }).then(() => {
        viewer = new DC.Viewer('viewer-container')
        const global = appContext.config.globalProperties
        global.$viewer = viewer
        store.setLoadMap(true)
      })
    })
  }
  initMap()
  return {
  }
}