shuishen
2022-03-18 bf58722dfd03ea1513f3acc7331d4d4403fca76e
src/components/map/components/dimension.vue
@@ -1,383 +1,1004 @@
<template>
    <div class="dimension-cut">
        <el-radio-group v-model="dimensionValue"
                        size="medium"
                        @change="dimensionChange">
            <el-radio-button label="3 维"></el-radio-button>
            <el-radio-button label="2.5维"></el-radio-button>
        <el-button
            v-show="btnGroupShow"
            size="mini"
            class="three-stm"
            type="primary"
            @click="locationSTM"
        >s3m</el-button>
        <el-button
            v-show="btnGroupShow"
            size="mini"
            class="sat-stm"
            type="primary"
            @click="locationSAT"
        >科技</el-button>
        <el-radio-group v-model="dimensionValue" size="medium" @change="dimensionChange">
            <el-radio-button label="三 维"></el-radio-button>
            <el-radio-button label="真三维"></el-radio-button>
        </el-radio-group>
    </div>
</template>
<script>
import axios from 'axios'
import { mapGetters } from 'vuex'
import { getDetail } from '@/api/pc/public/arc'
let tilesetLayer = null
let tileset = null
let silhouetteBlue = null
let baseMapLayer = null
let DefaultAreaLayer = null
let layerGroup = null
let select = null
let streenMlayer = null
let layerSat = null
let layerSATtwo = null
const wallLayer = null
export default {
    name: 'dimension',
    data () {
        return {
            DC: null,
            dimensionValue: '3 维',
            newLayer: null,
            provider: null,
            wallLayer: null,
            tileset: null,
            tilesetLayer: null,
            btnGroupShow: false,
            dimensionValue: '三 维',
            // 建筑2.5D地图
            // 建筑2.5D面数据
            titlesetLayerFlag: false,
            silhouetteBlue: null,
            wallArr: [
                [116.41526036, 27.95352217, 100],
                [116.41128018, 27.95789328, 100],
                [116.40246486, 27.96397110, 100],
                [116.39728537, 27.96779573, 100],
                [116.39588026, 27.96862679, 100],
                [116.38903705, 27.97029865, 100],
                [116.38872398, 27.97051829, 100],
                [116.38892229, 27.97090120, 100],
                [116.38906721, 27.97190632, 100],
                [116.38706808, 27.97195638, 100],
                [116.38649076, 27.97114448, 100],
                [116.38214070, 27.97312735, 100],
                [116.37876213, 27.97582549, 100],
                [116.37851310, 27.97664153, 100],
                [116.37634915, 27.98039526, 100],
                [116.37439220, 27.98131916, 100],
                [116.36995935, 27.97936074, 100],
                [116.37217247, 27.97498147, 100],
                [116.35099819, 27.97539586, 100],
                [116.35103749, 27.98088050, 100],
                [116.33972460, 27.97987911, 100],
                [116.33950071, 27.97372028, 100],
                [116.32313266, 27.97004136, 100],
                [116.32606743, 27.95863979, 100],
                [116.34788837, 27.92538024, 100],
                [116.34566310, 27.92338627, 100],
                [116.34874490, 27.91718915, 100],
                [116.35311999, 27.91804451, 100],
                [116.35109257, 27.92284807, 100],
                [116.35975153, 27.92900526, 100],
                [116.35660704, 27.93816236, 100],
                [116.39585177, 27.93945304, 100],
                [116.41526036, 27.95352217, 100]
            ]
                [114.04006133, 27.628038, 100],
                [114.04020623, 27.62809403, 100],
                [114.04025389, 27.62819931, 100],
                [114.04032823, 27.62827743, 100],
                [114.0410871, 27.62918798, 100],
                [114.04001425, 27.62986815, 100],
                [114.04001615, 27.62986817, 100],
                [114.03992451, 27.62998379, 100],
                [114.03967878, 27.62999684, 100],
                [114.03940001, 27.63008698, 100],
                [114.03951075, 27.63047135, 100],
                [114.03946107, 27.63056152, 100],
                [114.03927571, 27.63072325, 100],
                [114.03871751, 27.63128845, 100],
                [114.03872079, 27.63135594, 100],
                [114.03869211, 27.63139169, 100],
                [114.03960653, 27.63200726, 100],
                [114.03945732, 27.63215207, 100],
                [114.03760837, 27.63092563, 100],
                [114.03770336, 27.63078037, 100],
                [114.03782957, 27.63072932, 100],
                [114.03787347, 27.63068209, 100],
                [114.03824591, 27.62887902, 100],
                [114.03837943, 27.6289105, 100],
                [114.03863853, 27.62868839, 100],
                [114.03905656, 27.62843592, 100],
                [114.03954722, 27.62819644, 100],
                [114.04006133, 27.628038, 100]
            ],
            mapCenter: [115.871863, 28.743861, 400.0]
        }
    },
    computed: {
        ...mapGetters([
            'viewer',
            // 校内导航的显示关闭
            'viewerExist',
            // 校区内导航的显示关闭
            'campusNavFlag',
            'orgNavBarFlag',
            'arcNavBarFlag'
            'arcNavBarFlag',
            'closeMapClick' // 关闭地图点击,防止新增标签误触
        ])
    },
    created () {
        this.DC = global.DC
        select = {
            overlay: null,
            color: null
        }
    },
    watch: {
        viewer: {
        viewerExist: {
            immediate: true,
            handler (newCode, oldCode) {
                if (this.titlesetLayerFlag == false && newCode != null) {
                if (this.titlesetLayerFlag == false && newCode == true) {
                    var that = this
                    that.tilesetLayer = new that.DC.TilesetLayer('tilesetLayer')
                    that.viewer.addLayer(that.tilesetLayer)
                    that.tileset = new that.DC.Tileset(
                        '/mx/tileset.json',
                        {
                            luminanceAtZenith: 0.5
                    silhouetteBlue =
                        global.DC.Namespace.Cesium.PostProcessStageLibrary.createEdgeDetectionStage()
                    silhouetteBlue.uniforms.color =
                        global.DC.Namespace.Cesium.Color.fromBytes(9, 162, 40)
                    silhouetteBlue.uniforms.length = 0.01
                    silhouetteBlue.selected = []
                    global.viewer.scene.postProcessStages.add(
                        global.DC.Namespace.Cesium.PostProcessStageLibrary.createSilhouetteStage(
                            [silhouetteBlue]
                        )
                    )
                    global.viewer.imageryLayers.addImageryProvider(
                        new global.DC.Namespace.Cesium.UrlTemplateImageryProvider({
                            url: 'http://t{s}.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=9ae78c51a0a28f06444d541148496e36',
                            subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
                            format: 'image/jpeg',
                            show: true,
                            maximumLevel: 18
                        })
                    )
                    global.viewer.imageryLayers.addImageryProvider(
                        new global.DC.Namespace.Cesium.UrlTemplateImageryProvider({
                            url: 'http://t{s}.tianditu.gov.cn/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=9ae78c51a0a28f06444d541148496e36',
                            subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
                            format: 'image/jpeg',
                            show: true,
                            maximumLevel: 18
                        })
                    )
                    // global.viewer.imageryLayers.addImageryProvider(
                    //     new global.DC.Namespace.Cesium.WebMapTileServiceImageryProvider({
                    //         url: ' http://t1.tianditu.gov.cn/vec_w/wmts?tk=9ae78c51a0a28f06444d541148496e36',
                    //         type: 'wmts',
                    //         layer: 'vec',
                    //         style: 'default',
                    //         format: 'tiles',
                    //         tileMatrixSetID: 'w',
                    //         show: true,
                    //         maximumLevel: 18
                    //     })
                    // )
                    // global.viewer.imageryLayers.addImageryProvider(
                    //     new global.DC.Namespace.Cesium.WebMapTileServiceImageryProvider({
                    //         url: ' http://t1.tianditu.gov.cn/cva_w/wmts?tk=9ae78c51a0a28f06444d541148496e36',
                    //         type: 'wmts',
                    //         layer: 'cva',
                    //         style: 'default',
                    //         format: 'tiles',
                    //         tileMatrixSetID: 'w',
                    //         show: true,
                    //         maximumLevel: 18
                    //     })
                    // )
                    const videoLayer = new global.DC.CameraVideoLayer('video-layer').addTo(
                        global.viewer
                    )
                    const cameraVideo = new global.DC.CameraVideo(
                        new global.DC.Position(114.03935976, 27.62939045, 100.25, 4.2, -90),
                        document.getElementById('video')
                    )
                    cameraVideo.setStyle({
                        fov: 30,
                        far: 120,
                        near: 1,
                        aspectRatio: 1.3,
                        alpha: 0.7
                    })
                    videoLayer.addOverlay(cameraVideo)
                    baseMapLayer =
                        global.viewer.imageryLayers.addImageryProvider(new global.DC.Namespace.Cesium.UrlTemplateImageryProvider({
                            url: '/wp/{z}/{x}/{y}.png',
                            fileExtension: 'png'
                            // minimumLevel: 19
                        }))
                    // wallLayer = new global.DC.VectorLayer('wallLayer')
                    // global.viewer.addLayer(wallLayer)
                    // that.wallArr.forEach((item) => {
                    //     item = item.join(',')
                    // })
                    // that.wallArr = that.wallArr.join(';')
                    // const wall = new global.DC.Wall(that.wallArr)
                    // wall.setStyle({
                    //     material: new global.DC.WallTrailMaterialProperty({
                    //         color: global.DC.Namespace.Cesium.Color.fromBytes(0, 142, 255, 150),
                    //         // color: global.DC.Color.CYAN,
                    //         speed: 10
                    //     })
                    // })
                    // wallLayer.addOverlay(wall)
                    // global.viewer.camera.setView({
                    //     // Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
                    //     // fromDegrees()方法,将经纬度和高程转换为世界坐标
                    //     destination: global.DC.Namespace.Cesium.Cartesian3.fromDegrees(114.03928791, 27.62954732, 400.0),
                    //     orientation: {
                    //         // 指向
                    //         heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
                    //         // 视角
                    //         pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
                    //         roll: 0.0
                    //     }
                    // })
                    // setTimeout(() => {
                    //     global.viewer.camera.flyTo({
                    //         // Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
                    //         // fromDegrees()方法,将经纬度和高程转换为世界坐标
                    //         destination: global.DC.Namespace.Cesium.Cartesian3.fromDegrees(114.0351, 27.6314, 200.0),
                    //         duration: 5,
                    //         complete: () => {
                    //             global.viewer.camera.flyTo({
                    //                 // Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
                    //                 // fromDegrees()方法,将经纬度和高程转换为世界坐标
                    //                 destination: global.DC.Namespace.Cesium.Cartesian3.fromDegrees(114.0351, 27.6314, 200.0),
                    //                 orientation: {
                    //                     // 指向
                    //                     heading: global.DC.Namespace.Cesium.Math.toRadians(108),
                    //                     // 视角
                    //                     pitch: global.DC.Namespace.Cesium.Math.toRadians(-26.46),
                    //                     roll: 0.0
                    //                 }
                    //             })
                    //         }
                    //     })
                    // }, 400)
                    that.titlesetLayerFlag = true
                    global.viewer.camera.setView({
                        // Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
                        // fromDegrees()方法,将经纬度和高程转换为世界坐标
                        destination: global.DC.Namespace.Cesium.Cartesian3.fromDegrees(
                            that.mapCenter[0],
                            that.mapCenter[1],
                            that.mapCenter[2]
                        ),
                        orientation: {
                            // 指向
                            heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
                            // 视角
                            pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
                            roll: 0.0
                        }
                    )
                    that.tilesetLayer.addOverlay(that.tileset)
                    })
                    that.silhouetteBlue = that.DC.Namespace.Cesium.PostProcessStageLibrary.createEdgeDetectionStage()
                    that.silhouetteBlue.uniforms.color = that.DC.Namespace.Cesium.Color.fromBytes(9, 162, 40)
                    that.silhouetteBlue.uniforms.length = 0.01
                    that.silhouetteBlue.selected = []
                    // 最小
                    global.viewer.scene.screenSpaceCameraController.minimumZoomDistance = 100
                    // 最大
                    global.viewer.scene.screenSpaceCameraController.maximumZoomDistance = 400
                    that.viewer.scene.postProcessStages.add(
                        that.DC.Namespace.Cesium.PostProcessStageLibrary.createSilhouetteStage([
                            that.silhouetteBlue
                    // 设置相机缩小时的速率
                    global.viewer.scene.screenSpaceCameraController._minimumZoomRate = 2000
                    // 设置相机放大时的速率
                    global.viewer.scene.screenSpaceCameraController._maximumZoomRate = 5906376272000
                    // 视角平移
                    global.viewer.scene.screenSpaceCameraController.enableRotate = true
                    // 视角缩放
                    global.viewer.scene.screenSpaceCameraController.enableZoom = true
                    // 视角旋转
                    global.viewer.scene.screenSpaceCameraController.enableTilt = false
                    that.createdLayers()
                    global.viewer.on(global.DC.MouseEventType.MOUSE_MOVE, that.mouseMoveEvent)
                    global.viewer.on(global.DC.MouseEventType.CLICK, (e) => {
                        if (that.closeMapClick) {
                            return
                        }
                        if (e.overlay != undefined && e.layer.id == 'DefaultAreaLayer') {
                            var rid =
                                e.overlay.attr['楼栋号'] == '8栋'
                                    ? '9栋'
                                    : e.overlay.attr['楼栋号'] == '9栋'
                                        ? '8栋'
                                        : e.overlay.attr['楼栋号']
                            this.$store.commit('CLEAR_ALL', null)
                            getDetail({ mechanismname: '香琴湾' + rid }).then((res) => {
                                global.viewer.scene.globe.depthTestAgainstTerrain = false
                                var result = res.data.data
                                var imgArr = result.tpurl.split(',')
                                this.$store.commit('SET_POPUPBGURL', imgArr[0])
                                this.$store.commit('SET_POPUPQRURL', result.codeurl)
                                this.$store.commit('SET_POINTPOSITION', [
                                    Number(e.wgs84Position.lng),
                                    Number(e.wgs84Position.lat),
                                    Number(e.wgs84Position.alt),
                                    Number(0),
                                    Number(0),
                                    Number(0)
                                ])
                                this.$store.commit('SET_STATENAME', result.mechanismname)
                                this.$store.commit('SET_SITENAME', result.address)
                                this.$store.commit('SET_TELEPHONE', result.telephone)
                                this.$store.commit('SET_INTRODUCETEXT', result.introduce)
                                this.$store.commit('SET_PANORAMAURL', result.panoramaurl)
                                this.$store.commit('SET_POPUPIMGATLAS', imgArr)
                                if (result.videourl && result.videourl != '') {
                                    this.$store.commit('SET_MONITORURL', result.videourl)
                                }
                                if (result.jx != undefined && result.jx != '') {
                                    var tabOne = res.data.data[0].jx.split(',')
                                    this.$store.commit('SET_TEACHLIST', tabOne)
                                } else {
                                    this.$store.commit('SET_TEACHLIST', [])
                                }
                                if (result.sh != undefined && result.sh != '') {
                                    var tabTwo = res.data.data[0].sh.split(',')
                                    this.$store.commit('SET_LIVELIST', tabTwo)
                                } else {
                                    this.$store.commit('SET_LIVELIST', [])
                                }
                                // 定制化窗体
                                // eslint-disable-next-line no-unused-vars
                                var popup = new global.DC.DivForms(global.viewer, {
                                    domId: 'divFormsDomBox',
                                    position: [
                                        global.DC.Transform.transformWGS84ToCartesian(
                                            new global.DC.Position(
                                                Number(e.wgs84Position.lng),
                                                Number(e.wgs84Position.lat),
                                                Number(e.wgs84Position.alt)
                                            )
                                        )
                                    ]
                                })
                                this.$store.commit('SET_PANORAMAPOPUP', false)
                                this.$store.commit('SET_MONITORPOPUP', false)
                                this.$store.commit('SET_DETAILSPOPUP', true)
                            })
                            global.viewer.flyToPosition(
                                new global.DC.Position(
                                    Number(e.wgs84Position.lng),
                                    Number(e.wgs84Position.lat),
                                    300,
                                    Number(0),
                                    Number(-90),
                                    Number(0)
                                ),
                                () => { },
                                0
                            )
                        }
                    })
                    document.querySelector('.dc-zoom-controller').children[1].onclick =
                        function () {
                            if (that.dimensionValue == '真三维') {
                                global.viewer.camera.setView({
                                    // Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
                                    // fromDegrees()方法,将经纬度和高程转换为世界坐标
                                    destination: global.DC.Namespace.Cesium.Cartesian3.fromDegrees(
                                        that.mapCenter[0],
                                        that.mapCenter[1],
                                        220.0
                                    ),
                                    orientation: {
                                        // 指向
                                        heading: global.DC.Namespace.Cesium.Math.toRadians(-9),
                                        // 视角
                                        pitch: global.DC.Namespace.Cesium.Math.toRadians(-34.54),
                                        roll: 0.0
                                    }
                                })
                            } else {
                                global.viewer.camera.setView({
                                    // Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
                                    // fromDegrees()方法,将经纬度和高程转换为世界坐标
                                    destination: global.DC.Namespace.Cesium.Cartesian3.fromDegrees(
                                        that.mapCenter[0],
                                        that.mapCenter[1],
                                        400.0
                                    ),
                                    orientation: {
                                        // 指向
                                        heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
                                        // 视角
                                        pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
                                        roll: 0.0
                                    }
                                })
                            }
                        }
                    document.querySelector('.dc-zoom-controller').children[2].onclick =
                        function () {
                            if (
                                that.dimensionValue != undefined &&
                                that.dimensionValue != '真三维'
                            ) {
                                const height = Math.ceil(
                                    global.viewer.camera.positionCartographic.height
                                )
                                if (height < 150) {
                                    global.viewer.camera.setView({
                                        destination:
                                            global.DC.Namespace.Cesium.Cartesian3.fromRadians(
                                                global.viewer.camera.positionCartographic.longitude,
                                                global.viewer.camera.positionCartographic.latitude,
                                                200
                                            ),
                                        orientation: {
                                            // 指向
                                            heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
                                            // 视角
                                            pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
                                            roll: 0.0
                                        }
                                    })
                                    return
                                }
                                if (height < 250) {
                                    global.viewer.camera.setView({
                                        destination:
                                            global.DC.Namespace.Cesium.Cartesian3.fromRadians(
                                                global.viewer.camera.positionCartographic.longitude,
                                                global.viewer.camera.positionCartographic.latitude,
                                                300
                                            ),
                                        orientation: {
                                            // 指向
                                            heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
                                            // 视角
                                            pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
                                            roll: 0.0
                                        }
                                    })
                                    return
                                }
                                if (height < 350) {
                                    global.viewer.camera.setView({
                                        destination:
                                            global.DC.Namespace.Cesium.Cartesian3.fromRadians(
                                                global.viewer.camera.positionCartographic.longitude,
                                                global.viewer.camera.positionCartographic.latitude,
                                                400
                                            ),
                                        orientation: {
                                            // 指向
                                            heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
                                            // 视角
                                            pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
                                            roll: 0.0
                                        }
                                    })
                                }
                            }
                        }
                    document.querySelector('.dc-zoom-controller').children[0].onclick =
                        function () {
                            if (
                                that.dimensionValue != undefined &&
                                that.dimensionValue != '真三维'
                            ) {
                                const height = Math.ceil(
                                    global.viewer.camera.positionCartographic.height
                                )
                                if (height > 350) {
                                    global.viewer.camera.setView({
                                        destination:
                                            global.DC.Namespace.Cesium.Cartesian3.fromRadians(
                                                global.viewer.camera.positionCartographic.longitude,
                                                global.viewer.camera.positionCartographic.latitude,
                                                300
                                            ),
                                        orientation: {
                                            // 指向
                                            heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
                                            // 视角
                                            pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
                                            roll: 0.0
                                        }
                                    })
                                    return
                                }
                                if (height > 250) {
                                    global.viewer.camera.setView({
                                        destination:
                                            global.DC.Namespace.Cesium.Cartesian3.fromRadians(
                                                global.viewer.camera.positionCartographic.longitude,
                                                global.viewer.camera.positionCartographic.latitude,
                                                200
                                            ),
                                        orientation: {
                                            // 指向
                                            heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
                                            // 视角
                                            pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
                                            roll: 0.0
                                        }
                                    })
                                    return
                                }
                                if (height > 150) {
                                    global.viewer.camera.setView({
                                        destination:
                                            global.DC.Namespace.Cesium.Cartesian3.fromRadians(
                                                global.viewer.camera.positionCartographic.longitude,
                                                global.viewer.camera.positionCartographic.latitude,
                                                100
                                            ),
                                        orientation: {
                                            // 指向
                                            heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
                                            // 视角
                                            pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
                                            roll: 0.0
                                        }
                                    })
                                }
                            }
                        }
                    global.viewer.on(global.DC.SceneEventType.CAMERA_CHANGED, that.mapCameraEvent)
                }
            }
        }
    },
    methods: {
        locationSTM () {
            global.viewer.flyToPosition('116.45793269658417,39.92711385557482,617.5967826044838,181.95219395269424,-21.286437065473546')
        },
        mouseMoveEvent (e) {
            var that = this
            if (that.closeMapClick) {
                return
            }
            if (e.overlay != undefined && e.overlay != null && e.layer.id == 'DefaultAreaLayer') {
                if (select.overlay != null) {
                    if (e.overlay != select.overlay) {
                        select.overlay.setStyle({
                            material: select.color,
                            outline: false
                        })
                        select.overlay = null
                        select.color = null
                    }
                }
                if (select.overlay == null) {
                    select.overlay = e.overlay
                    select.color = e.overlay._style.material
                    select.overlay.setStyle({
                        outline: true,
                        outlineColor: global.DC.Namespace.Cesium.Color.fromBytes(
                            3,
                            255,
                            13,
                            255
                        ), // 边框颜色
                        outlineWidth: 10, // 边框大小,
                        height: 0.01,
                        material: global.DC.Namespace.Cesium.Color.fromBytes(
                            108,
                            245,
                            113,
                            158
                        )
                    })
                }
            } else {
                if (select.overlay != null) {
                    select.overlay.setStyle({
                        material: select.color,
                        outline: false
                    })
                    select.overlay = null
                    select.color = null
                }
            }
        },
        mapCameraEvent () {
            const height = Math.ceil(
                global.viewer.camera.positionCartographic.height
            )
            global.viewer.camera.setView({
                orientation: {
                    // 指向
                    heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
                    // 视角
                    pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
                    roll: 0.0
                }
            })
            if (height < 150) {
                global.viewer.camera.setView({
                    destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
                        global.viewer.camera.positionCartographic.longitude,
                        global.viewer.camera.positionCartographic.latitude,
                        100
                    ),
                    orientation: {
                        // 指向
                        heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
                        // 视角
                        pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
                        roll: 0.0
                    }
                })
            }
            if (height > 150 && height <= 250) {
                global.viewer.camera.setView({
                    destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
                        global.viewer.camera.positionCartographic.longitude,
                        global.viewer.camera.positionCartographic.latitude,
                        200
                    ),
                    orientation: {
                        // 指向
                        heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
                        // 视角
                        pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
                        roll: 0.0
                    }
                })
            }
            if (height > 250 && height <= 350) {
                global.viewer.camera.setView({
                    destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
                        global.viewer.camera.positionCartographic.longitude,
                        global.viewer.camera.positionCartographic.latitude,
                        300
                    ),
                    orientation: {
                        // 指向
                        heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
                        // 视角
                        pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
                        roll: 0.0
                    }
                })
            }
            if (height > 350) {
                global.viewer.camera.setView({
                    destination: global.DC.Namespace.Cesium.Cartesian3.fromRadians(
                        global.viewer.camera.positionCartographic.longitude,
                        global.viewer.camera.positionCartographic.latitude,
                        400
                    ),
                    orientation: {
                        // 指向
                        heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
                        // 视角
                        pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
                        roll: 0.0
                    }
                })
            }
        },
        createdLayers () {
            layerGroup = new global.DC.LayerGroup('modelBox')
            global.viewer.addLayerGroup(layerGroup)
            DefaultAreaLayer = new global.DC.VectorLayer('DefaultAreaLayer')
            layerGroup.addLayer(DefaultAreaLayer)
            axios
                .get(
                    'http://arcgis.jxpskj.com:6080/arcgis/rest/services/lxxqwxq/MapServer/0/query?where=1%3D1&text=&objectIds=&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&outFields=*&returnGeometry=true&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&returnTrueCurves=false&resultOffset=&resultRecordCount=&f=pjson'
                )
                .then((resultData) => {
                    resultData.data.features.forEach((item) => {
                        item.geometry.rings[0].forEach((it) => {
                            it = it.join(',')
                        })
                        item.geometry.rings[0] = item.geometry.rings[0].join(';')
                        const polygon = new global.DC.Polygon(item.geometry.rings[0])
                        polygon.attr = item.attributes
                        polygon.setStyle({
                            material: global.DC.Namespace.Cesium.Color.fromBytes(
                                255,
                                255,
                                255,
                                1
                            )
                        })
                        DefaultAreaLayer.addOverlay(polygon)
                    })
                })
        },
        removeLayers () {
            layerGroup.removeLayer(DefaultAreaLayer)
            DefaultAreaLayer = null
            global.viewer.removeLayerGroup(layerGroup)
            layerGroup = null
        },
        tilesetClick (e) {
            var that = this
            if (that.closeMapClick) {
                return
            }
            global.viewer.scene.globe.depthTestAgainstTerrain = false
            if (e.overlay && e.overlay.attr.arcName != null) {
                this.$store.commit('CLEAR_ALL', null)
                getDetail({
                    mechanismname: e.overlay.attr.arcName
                }).then((res) => {
                    if (res && JSON.stringify(res.data.data) != '{}') {
                        var result = res.data.data
                        var imgArr = result.tpurl.split(',')
                        this.$store.commit('SET_POPUPBGURL', imgArr[0])
                        this.$store.commit('SET_POPUPQRURL', result.codeurl)
                        this.$store.commit('SET_POINTPOSITION', [
                            Number(e.wgs84Position.lng),
                            Number(e.wgs84Position.lat),
                            Number(e.wgs84Position.alt),
                            Number(0),
                            Number(0),
                            Number(0)
                        ])
                    )
                        this.$store.commit('SET_STATENAME', result.mechanismname)
                        this.$store.commit('SET_SITENAME', result.address)
                        this.$store.commit('SET_TELEPHONE', result.telephone)
                        this.$store.commit('SET_INTRODUCETEXT', result.introduce)
                        this.$store.commit('SET_PANORAMAURL', result.panoramaurl)
                        this.$store.commit('SET_POPUPIMGATLAS', imgArr)
                        if (result.videourl && result.videourl != '') {
                            this.$store.commit('SET_MONITORURL', result.videourl)
                        }
                        if (result.jx != undefined && result.jx != '') {
                            var tabOne = res.data.data[0].jx.split(',')
                            this.$store.commit('SET_TEACHLIST', tabOne)
                        } else {
                            this.$store.commit('SET_TEACHLIST', [])
                        }
                    var highlighted = {
                        feature: undefined,
                        originalColor: new that.DC.Namespace.Cesium.Color()
                    }
                    var selected = {
                        feature: undefined,
                        originalColor: new that.DC.Namespace.Cesium.Color()
                    }
                    that.tileset.on(that.DC.MouseEventType.CLICK, e => {
                        that.viewer.scene.globe.depthTestAgainstTerrain = false
                        that.$store.commit('CLEAR_ALL', null)
                        var imgArr = ['http://223.82.109.183:2081/zhxy/upload/20211222/f66dc4527eb4cc1b2d33fa3a5b345ed0.jpg']
                        that.$store.commit('SET_POPUPBGURL', imgArr[0])
                        that.$store.commit('SET_POPUPQRURL', 'http://223.82.109.183:2081/zhxy/upload/20211222/9c324adea5d9e5b50cd8f874d5f780f4.png')
                        that.$store.commit('SET_POINTPOSITION', [Number(e.wgs84Position.lng), Number(e.wgs84Position.lat), Number(e.wgs84Position.alt), Number(0), Number(0), Number(0)])
                        that.$store.commit('SET_STATENAME', e.overlay.attr.name)
                        that.$store.commit('SET_SITENAME', e.overlay.attr['地址'])
                        that.$store.commit('SET_POPUPIMGATLAS', imgArr)
                        if (result.sh != undefined && result.sh != '') {
                            var tabTwo = res.data.data[0].sh.split(',')
                            this.$store.commit('SET_LIVELIST', tabTwo)
                        } else {
                            this.$store.commit('SET_LIVELIST', [])
                        }
                        // 定制化窗体
                        // eslint-disable-next-line no-unused-vars
                        var popup = new that.DC.DivForms(that.viewer, {
                        var popup = new global.DC.DivForms(global.viewer, {
                            domId: 'divFormsDomBox',
                            position: [
                                that.DC.Transform.transformWGS84ToCartesian(new that.DC.Position(Number(e.wgs84Position.lng), Number(e.wgs84Position.lat), Number(e.wgs84Position.alt)))
                                global.DC.Transform.transformWGS84ToCartesian(
                                    new global.DC.Position(
                                        Number(e.wgs84Position.lng),
                                        Number(e.wgs84Position.lat),
                                        Number(e.wgs84Position.alt)
                                    )
                                )
                            ]
                        })
                        this.$store.commit('SET_PANORAMAPOPUP', false)
                        this.$store.commit('SET_MONITORPOPUP', false)
                        this.$store.commit('SET_DETAILSPOPUP', true)
                    })
                    that.tileset.on(that.DC.MouseEventType.MOUSE_MOVE, e => {
                        that.silhouetteBlue.selected = []
                        if (that.DC.Namespace.Cesium.defined(highlighted.feature)) {
                            highlighted.feature.color = highlighted.originalColor
                            highlighted.feature = undefined
                        }
                        if (e.feature !== selected.feature) {
                            that.silhouetteBlue.selected = [e.feature]
                            highlighted.feature = e.feature
                            that.DC.Namespace.Cesium.Color.clone(
                                e.feature.color,
                                highlighted.originalColor
                            )
                            e.feature.color = that.DC.Namespace.Cesium.Color.fromBytes(155, 255, 175)
                        }
                    })
                    // var provider = new that.DC.Namespace.Cesium.WebMapTileServiceImageryProvider({
                    //     url: 'http://www.tdtfz.com/OneMapServer/rest/services/fzsw2019/MapServer/WMTS/tile/1.0.0/fzsw2019/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}',
                    //     layer: 'fzsw2019',
                    //     style: 'default',
                    //     tileMatrixSetID: 'default028mm',
                    //     format: 'image/jpgpng',
                    //     tilingScheme: new that.DC.Namespace.Cesium.GeographicTilingScheme(),
                    //     maximumLevel: 19,
                    //     tileMatrixLabels: [
                    //         '0',
                    //         '1',
                    //         '2',
                    //         '3',
                    //         '4',
                    //         '5',
                    //         '6',
                    //         '7',
                    //         '8',
                    //         '9',
                    //         '10',
                    //         '11',
                    //         '12',
                    //         '13',
                    //         '14',
                    //         '15',
                    //         '16',
                    //         '17',
                    //         '18',
                    //         '19'
                    //     ]
                    // })
                    // var provider = new that.DC.Namespace.Cesium.ArcGisMapServerImageryProvider({
                    //     url: 'http://arcgis.jxpskj.com:6080/arcgis/rest/services/PingXiang25DMapDN/MapServer'
                    // })
                    // that.newLayer = that.viewer.imageryLayers.addImageryProvider(provider)
                    that.wallLayer = new that.DC.VectorLayer('wallLayer')
                    // that.viewer.addLayer(that.wallLayer)
                    that.wallArr.forEach(item => {
                        item = item.join(',')
                    })
                    that.wallArr = that.wallArr.join(';')
                    const wall = new that.DC.Wall(
                        that.wallArr
                    )
                    wall.setStyle({
                        material: new that.DC.WallTrailMaterialProperty({
                            color: that.DC.Namespace.Cesium.Color.fromBytes(0, 142, 255, 150),
                            // color: that.DC.Color.CYAN,
                            speed: 10
                        })
                    })
                    // that.wallLayer.addOverlay(wall)
                    // that.viewer.camera.setView({
                    //     // Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
                    //     // fromDegrees()方法,将经纬度和高程转换为世界坐标
                    //     destination: that.DC.Namespace.Cesium.Cartesian3.fromDegrees(114.03928791, 27.62954732, 1000.0),
                    //     orientation: {
                    //         // 指向
                    //         heading: that.DC.Namespace.Cesium.Math.toRadians(0, 0),
                    //         // 视角
                    //         pitch: that.DC.Namespace.Cesium.Math.toRadians(-90),
                    //         roll: 0.0
                    //     }
                    // })
                    that.tilesetLayer.show = true
                    setTimeout(() => {
                        that.viewer.flyTo(that.tileset)
                    }, 2000)
                    that.titlesetLayerFlag = true
                    // 最小
                    that.viewer.scene.screenSpaceCameraController.minimumZoomDistance = 1.0
                    // 最大
                    that.viewer.scene.screenSpaceCameraController.maximumZoomDistance = Number.POSITIVE_INFINITY
                    // 设置相机缩小时的速率
                    // that.viewer.scene.screenSpaceCameraController._minimumZoomRate = 30000
                    // 设置相机放大时的速率
                    that.viewer.scene.screenSpaceCameraController._maximumZoomRate = 5906376272000
                    // 视角平移
                    that.viewer.scene.screenSpaceCameraController.enableRotate = true
                    // 视角缩放
                    that.viewer.scene.screenSpaceCameraController.enableZoom = true
                    // 视角旋转
                    that.viewer.scene.screenSpaceCameraController.enableTilt = true
                }
            }
        }
    },
    methods: {
        dimensionChange () {
            var that = this
            if (that.dimensionValue == '3 维') {
                that.wallLayer.show = false
                that.viewer.imageryLayers.remove(that.newLayer)
                that.newLayer = null
                that.silhouetteBlue.selected = []
                that.tilesetLayer.show = true
                that.viewer.flyTo(that.tileset)
                that.viewer.off(that.DC.SceneEventType.CAMERA_CHANGED, that.camerAzoom())
                // 最小
                that.viewer.scene.screenSpaceCameraController.minimumZoomDistance = 1.0
                // 最大
                that.viewer.scene.screenSpaceCameraController.maximumZoomDistance = Number.POSITIVE_INFINITY
                // 视角旋转
                that.viewer.scene.screenSpaceCameraController.enableTilt = true
            } else {
                that.tilesetLayer.show = false
                var provider = new that.DC.Namespace.Cesium.WebMapTileServiceImageryProvider({
                    url: 'http://www.tdtfz.com/OneMapServer/rest/services/fzsw2019/MapServer/WMTS/tile/1.0.0/fzsw2019/{Style}/{TileMatrixSet}/{TileMatrix}/{TileRow}/{TileCol}',
                    layer: 'fzsw2019',
                    style: 'default',
                    tileMatrixSetID: 'default028mm',
                    format: 'image/jpgpng',
                    tilingScheme: new that.DC.Namespace.Cesium.GeographicTilingScheme(),
                    maximumLevel: 19,
                    tileMatrixLabels: [
                        '0',
                        '1',
                        '2',
                        '3',
                        '4',
                        '5',
                        '6',
                        '7',
                        '8',
                        '9',
                        '10',
                        '11',
                        '12',
                        '13',
                        '14',
                        '15',
                        '16',
                        '17',
                        '18',
                        '19'
                    ]
                })
                that.newLayer = that.viewer.imageryLayers.addImageryProvider(provider)
                that.wallLayer.show = true
                that.viewer.camera.setView({
                    // Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
                    // fromDegrees()方法,将经纬度和高程转换为世界坐标
                    destination: that.DC.Namespace.Cesium.Cartesian3.fromDegrees(114.03928791, 27.62954732, 1000.0),
                    orientation: {
                        // 指向
                        heading: that.DC.Namespace.Cesium.Math.toRadians(0, 0),
                        // 视角
                        pitch: that.DC.Namespace.Cesium.Math.toRadians(-90),
                        roll: 0.0
                    }
                })
                that.viewer.on(that.DC.SceneEventType.CAMERA_CHANGED, that.camerAzoom())
                // 最小
                that.viewer.scene.screenSpaceCameraController.minimumZoomDistance = 500
                // 最大
                that.viewer.scene.screenSpaceCameraController.maximumZoomDistance = 6000
                // 视角旋转
                that.viewer.scene.screenSpaceCameraController.enableTilt = false
                global.viewer.flyToPosition(
                    new global.DC.Position(
                        Number(e.wgs84Position.lng + 0.00070806),
                        Number(e.wgs84Position.lat - 0.00261205),
                        300,
                        Number(-9),
                        Number(-34.54),
                        Number(0)
                    )
                )
            }
        },
        camerAzoom () {
            var that = this
            const height = Math.ceil(that.viewer.camera.positionCartographic.height)
        locationSAT () {
            global.viewer.flyToPosition('121.4941629,31.2091462,1859.56,0,-28.71')
        },
            that.viewer.camera.setView({
                orientation: {
                    // 指向
                    heading: that.DC.Namespace.Cesium.Math.toRadians(0, 0),
                    // 视角
                    pitch: that.DC.Namespace.Cesium.Math.toRadians(-90),
                    roll: 0.0
        // 科技感删除
        removeSAT () {
            global.viewer.remove(layerSat)
            global.viewer.remove(layerSATtwo)
        },
        // 科技感添加
        createSAT () {
            function generatePosition (num, isAdd) {
                const list = []
                for (let i = 0; i < num; i++) {
                    const lng = 121.49536592256028 + Math.random() * 0.04 * (isAdd ? 1 : -1)
                    const lat = 31.241616722278213 + Math.random() * 0.04 * (isAdd ? 1 : -1)
                    list.push({ lng, lat })
                }
            })
                return list
            }
            if (height < 100) {
                that.viewer.camera.setView({
                    destination: that.DC.Namespace.Cesium.Cartesian3.fromRadians(that.viewer.camera.positionCartographic.longitude, that.viewer.camera.positionCartographic.latitude, 100),
            layerSat = new global.DC.TilesetLayer('layerSat').addTo(global.viewer)
            const build = new global.DC.Tileset(
                'http://resource.dvgis.cn/data/3dtiles/ljz/tileset.json',
                { skipLevels: true }
            )
            const fs = `
                        varying vec3 v_positionEC;
                        void main(void){
                            vec4 position = czm_inverseModelView * vec4(v_positionEC,1); // 位置
                            float glowRange = 100.0; // 光环的移动范围(高度)
                            gl_FragColor = vec4(0.2,  0.5, 1.0, 1.0); // 颜色
                            gl_FragColor *= vec4(vec3(position.z / 100.0), 1.0); // 渐变
                            // 动态光环
                            float time = fract(czm_frameNumber / 360.0);
                            time = abs(time - 0.5) * 2.0;
                            float diff = step(0.005, abs( clamp(position.z / glowRange, 0.0, 1.0) - time));
                            gl_FragColor.rgb += gl_FragColor.rgb * (1.0 - diff);
                        }
                        `
            build.setCustomShader(fs)
            layerSat.addOverlay(build)
            layerSATtwo = new global.DC.PrimitiveLayer('layer').addTo(global.viewer)
            let positions = generatePosition(50, true)
            positions = positions.concat(generatePosition(50))
            positions.forEach(item => {
                const position = global.DC.Position.fromObject(item)
                const end = position.copy()
                end.alt = 5000 * Math.random()
                const line = new global.DC.FlowLinePrimitive([position, end], 0.5)
                line.setStyle({
                    speed: 6 * Math.random(),
                    color: global.DC.Color.fromCssColorString('rgb(141,172,172)'),
                    percent: 0.1,
                    gradient: 0.01
                })
                layerSATtwo.addOverlay(line)
            })
        },
        dimensionChange () {
            var that = this
            that.$store.commit('SET_TWOORTHREE', that.dimensionValue)
            if (that.dimensionValue == '真三维') {
                that.btnGroupShow = true
                that.createSAT()
                global.viewer.off(global.DC.MouseEventType.MOUSE_MOVE, that.mouseMoveEvent)
                global.viewer.off(global.DC.SceneEventType.CAMERA_CHANGED, that.mapCameraEvent)
                that.removeLayers()
                global.viewer.imageryLayers.remove(baseMapLayer)
                baseMapLayer = null
                silhouetteBlue.selected = []
                tilesetLayer = new global.DC.TilesetLayer('tilesetLayer')
                global.viewer.addLayer(tilesetLayer)
                tileset = new global.DC.Tileset('/mx/tileset.json', {
                    luminanceAtZenith: 0.4,
                    // cullWithChildrenBounds: false,
                    // cullRequestsWhileMoving: false,
                    // skipLevelOfDetail: false,
                    shadows: global.DC.Namespace.Cesium.ShadowMode.DISABLED
                })
                tilesetLayer.addOverlay(tileset)
                tileset.on(global.DC.MouseEventType.CLICK, that.tilesetClick)
                tilesetLayer.show = true
                streenMlayer = new global.DC.S3MLayer('streenMlayer', 'http://resource.dvgis.cn/data/3dtiles/CBD/cbd.scp')
                global.viewer.addLayer(streenMlayer)
                // 最小
                global.viewer.scene.screenSpaceCameraController.minimumZoomDistance = 1.0
                // 最大
                global.viewer.scene.screenSpaceCameraController.maximumZoomDistance =
                    Number.POSITIVE_INFINITY
                // 视角旋转
                global.viewer.scene.screenSpaceCameraController.enableTilt = true
                // 115.877863,28.741661
                global.viewer.camera.setView({
                    // Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
                    // fromDegrees()方法,将经纬度和高程转换为世界坐标
                    destination: global.DC.Namespace.Cesium.Cartesian3.fromDegrees(
                        that.mapCenter[0],
                        that.mapCenter[1],
                        220.0
                    ),
                    orientation: {
                        // 指向
                        heading: that.DC.Namespace.Cesium.Math.toRadians(0, 0),
                        heading: global.DC.Namespace.Cesium.Math.toRadians(-9),
                        // 视角
                        pitch: that.DC.Namespace.Cesium.Math.toRadians(-90),
                        pitch: global.DC.Namespace.Cesium.Math.toRadians(-34.54),
                        roll: 0.0
                    }
                })
            };
            if (height > 6000) {
                that.viewer.camera.setView({
                    destination: that.DC.Namespace.Cesium.Cartesian3.fromRadians(that.viewer.camera.positionCartographic.longitude, that.viewer.camera.positionCartographic.latitude, 6000),
            } else {
                that.btnGroupShow = false
                that.removeSAT()
                global.viewer.on(global.DC.MouseEventType.MOUSE_MOVE, that.mouseMoveEvent)
                global.viewer.on(global.DC.SceneEventType.CAMERA_CHANGED, that.mapCameraEvent)
                tileset.off(global.DC.MouseEventType.CLICK, that.tilesetClick)
                tilesetLayer.removeOverlay(tileset)
                tilesetLayer.show = false
                global.viewer.removeLayer(tilesetLayer)
                tileset = null
                tilesetLayer = null
                global.viewer.removeLayer(streenMlayer)
                streenMlayer = null
                that.createdLayers()
                baseMapLayer = global.viewer.imageryLayers.addImageryProvider(new global.DC.Namespace.Cesium.UrlTemplateImageryProvider({
                    url: '/wp/{z}/{x}/{y}.png',
                    fileExtension: 'png'
                }))
                global.viewer.camera.setView({
                    // Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
                    // fromDegrees()方法,将经纬度和高程转换为世界坐标
                    destination: global.DC.Namespace.Cesium.Cartesian3.fromDegrees(
                        that.mapCenter[0],
                        that.mapCenter[1],
                        400.0
                    ),
                    orientation: {
                        // 指向
                        heading: that.DC.Namespace.Cesium.Math.toRadians(0, 0),
                        heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
                        // 视角
                        pitch: that.DC.Namespace.Cesium.Math.toRadians(-90),
                        pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
                        roll: 0.0
                    }
                })
                // 最小
                global.viewer.scene.screenSpaceCameraController.minimumZoomDistance = 100
                // 最大
                global.viewer.scene.screenSpaceCameraController.maximumZoomDistance = 400
                // 视角旋转
                global.viewer.scene.screenSpaceCameraController.enableTilt = false
            }
        }
    }
}
</script>
<style lang='scss' scope>
<style lang="scss" scoped>
.dimension-cut {
    position: fixed;
    top: 100px;
@@ -386,4 +1007,18 @@
    // height: 40px;
    z-index: 1;
}
.three-stm {
    position: fixed;
    top: 66px;
    right: 10px;
    z-index: 99;
}
.sat-stm {
    position: fixed;
    top: 66px;
    right: 75px;
    z-index: 99;
}
</style>