智慧园区前端大屏
shuishen
2024-10-30 b2ad3aae15f93ff2d8e09701416e4b858c916ee8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2024-10-25 15:09:55
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2024-10-30 18:09:34
 * @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 Cesium = DC.getLib('Cesium')
  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)
 
        // 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)
      })
    })
  }
 
  initMap()
 
  return {
 
  }
}