From 7804a3a4d61ff1d857973e974bbdf78a2e17feab Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Fri, 17 Dec 2021 15:08:36 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.0.105:10010/r/school-web

---
 src/divForms/panoramaBox.js |   84 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 84 insertions(+), 0 deletions(-)

diff --git a/src/divForms/panoramaBox.js b/src/divForms/panoramaBox.js
new file mode 100644
index 0000000..5442d94
--- /dev/null
+++ b/src/divForms/panoramaBox.js
@@ -0,0 +1,84 @@
+/*
+ * @Descripttion:
+ * @version: 0.01
+ * @Author: Morpheus
+ * @Date: 2020-10-22 11:05:09
+ * @LastEditors: Morpheus
+ * @LastEditTime: 2020-10-22 13:48:22
+ */
+
+import DC from '@dvgis/dc-sdk/dist/dc.base.min' // 基础包
+import DcCore from '@dvgis/dc-sdk/dist/dc.core.min' // 核心包
+
+DC.use(DcCore) // 安装DC核心库
+
+class PanoramaBox {
+    /**
+     * @popup 存放 dom 相关
+     *
+     */
+    constructor (viewer, popup) {
+        this._viewer = viewer
+        this._popup = popup
+        this._position = popup.position
+        this.appendPopup()
+    }
+
+    get viewer () {
+        return this._viewer
+    }
+
+    get popup () {
+        return this._popup
+    }
+
+    get position () {
+        return this._position
+    }
+
+    appendPopup () {
+        /**
+         * @domId 存放 dom 的id, 多个数组,单个字符串
+         */
+
+        this.createVideoWindowAll(this._popup.domId)
+    }
+
+    // 创建元素并追加
+    createVideoWindowAll (id) {
+        this._viewer.scene.postRender.addEventListener(this.movePopup(id))
+    }
+
+    movePopup (id) {
+        var self = this
+        return function () {
+            const windowCoord = DC.Namespace.Cesium.SceneTransforms.wgs84ToWindowCoordinates(
+                self._viewer.scene,
+                self._position[0]
+            )
+
+            self.positionPopUp(windowCoord, id)
+        }
+    }
+
+    positionPopUp (windowCoord, id) {
+        if (document.getElementById(id) == null || document.getElementById(id) == undefined) {
+            this._viewer.scene.postRender.removeEventListener(this.movePopup(id))
+            return
+        }
+        if (windowCoord != undefined && windowCoord.x && windowCoord.x != undefined && !Number.isNaN(windowCoord.x) &&
+            windowCoord.y && windowCoord.y != undefined && !Number.isNaN(windowCoord.y)) {
+            const x = windowCoord.x
+            const y = windowCoord.y - document.getElementById(id).offsetHeight
+            // x = windowCoord.x - document.getElementById(id).offsetWidth
+
+            document.getElementById(id).style.cssText = `
+            visibility:visible;
+            z-index:1;
+            transform:translate3d(${Math.round(x)}px,${Math.round(y)}px, 0);
+            `
+        }
+    }
+}
+
+export default PanoramaBox

--
Gitblit v1.9.3