1
mayisheng
2022-08-15 81f54040c2cb65537c6c6e1db8358a39a57dea0d
src/divForms/panoramaBox.js
@@ -6,6 +6,7 @@
 * @LastEditors: Morpheus
 * @LastEditTime: 2020-10-22 13:48:22
 */
import store from '@/store/index'
class PanoramaBox {
    /**
     * @popup 存放 dom 相关
@@ -18,19 +19,19 @@
        this.appendPopup()
    }
    get viewer () {
    get viewer() {
        return this._viewer
    }
    get popup () {
    get popup() {
        return this._popup
    }
    get position () {
    get position() {
        return this._position
    }
    appendPopup () {
    appendPopup() {
        /**
         * @domId 存放 dom 的id, 多个数组,单个字符串
         */
@@ -39,23 +40,43 @@
    }
    // 创建元素并追加
    createVideoWindowAll (id) {
    createVideoWindowAll(id) {
        this._viewer.scene.postRender.addEventListener(this.movePopup(id))
    }
    movePopup (id) {
    movePopup(id) {
        var self = this
        return function () {
        return function() {
            var position = global.DC.Transform.transformCartesianToWGS84(self._position[0])
            var positionChange = null
            if (store.state.viewer.twoOrThree == '三 维') {
                positionChange = global.DC.Transform.transformWGS84ToCartesian(
                    new global.DC.Position(
                        Number(position.lng),
                        Number(position.lat),
                        Number(0)
                    )
                )
            } else {
                positionChange = global.DC.Transform.transformWGS84ToCartesian(
                    new global.DC.Position(
                        Number(position.lng),
                        Number(position.lat),
                        Number(50)
                    )
                )
            }
            const windowCoord = global.DC.Namespace.Cesium.SceneTransforms.wgs84ToWindowCoordinates(
                self._viewer.scene,
                self._position[0]
                positionChange
            )
            self.positionPopUp(windowCoord, id)
        }
    }
    positionPopUp (windowCoord, id) {
    positionPopUp(windowCoord, id) {
        if (document.getElementById(id) == null || document.getElementById(id) == undefined) {
            this._viewer.scene.postRender.removeEventListener(this.movePopup(id))
            return
@@ -64,7 +85,7 @@
            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
                // x = windowCoord.x - document.getElementById(id).offsetWidth
            document.getElementById(id).style.cssText = `
            visibility:visible;
@@ -75,4 +96,4 @@
    }
}
export default PanoramaBox
export default PanoramaBox