1
mayisheng
2022-08-15 81f54040c2cb65537c6c6e1db8358a39a57dea0d
src/components/map/index.vue
@@ -1,37 +1,30 @@
/* eslint-disable camelcase */
<template>
    <div id="viewer-container" style="height: 100%; width: 100%" @click="mapClick($event)">
        <video
            id="video"
            style="position: fixed; visibility: hidden"
            muted
            autoplay
            loop
            crossorigin
            controls
        >
            <source src="http://dc.dvgis.cn/examples/data/demo.mp4" type="video/mp4" />
        </video>
        <div
            style="
        position: fixed;
        left: 4px;
        bottom: 4px;
        width: 80px;
        line-height: 24px;
        text-align: center;
        color: #fff;
        font-size: 14px;
        border-radius: 4px;
        background: #2196f3ed;
        z-index: 11;
      "
                position: fixed;
                left: 4px;
                bottom: 4px;
                width: 80px;
                line-height: 24px;
                text-align: center;
                color: #fff;
                font-size: 14px;
                border-radius: 4px;
                background: #2196f3ed;
                z-index: 11;
            "
        >智慧校区</div>
        <dimension />
        <dimension
            :wheelFlag="wheelFlag"
            :startWheel="startWheel"
            :startSmallWheel="startSmallWheel"
            @change-wheel="changeWheel"
        />
        <!-- <calender /> -->
        <calender v-if="calenderShow" />
        <left-nav ref="leftNav"></left-nav>
@@ -65,12 +58,15 @@
    components: {
        mapPopup,
        campusBuildingSearch,
        dimension
        // calender
        dimension,
        calender
    },
    data () {
        return {
            samllMapFlag: false
            samllMapFlag: false,
            wheelFlag: true,
            startWheel: false,
            startSmallWheel: false
        }
    },
    watch: {
@@ -158,7 +154,8 @@
            'campusNavFlag',
            'orgNavBarFlag',
            'arcNavBarFlag',
            'searchPopupFlag'
            'searchPopupFlag',
            'calenderShow'
        ])
    },
    mounted () {
@@ -218,32 +215,51 @@
            global.viewer.measure.deactivate()
        }
        if (global.viewer != null) {
            global.viewer = null
            global.eagleViewer = null
        }
        function initViewer () {
            global.viewer = new global.DC.Viewer('viewer-container', {
                contextOptions: {
                    webgl: {
                        alpha: true,
                        stencil: true,
                        preserveDrawingBuffer: true
                    }
                }
            }).setOptions({
                // showAtmosphere: false, 大气层
                showMoon: true, // 月亮
                showSun: true, // 太阳
                skyBox: {
                    show: true
                }
            })
            global.viewer.scene.globe.baseColor = global.DC.Namespace.Cesium.Color.WHITE
            if (global.DC.Namespace.Cesium.FeatureDetection.supportsImageRenderingPixelated()) { // 判断是否支持图像渲染像素化处理
                global.viewer.setOptions({
                    resolutionScale: window.devicePixelRatio
                })
            }
            // 是否开启抗锯齿
            // global.viewer.scene.fxaa = true
            // global.viewer.scene.postProcessStages.fxaa.enabled = true
            // .setOptions({
            //     // showAtmosphere: false, 大气层
            //     showMoon: true, // 月亮
            //     showSun: true, // 太阳
            //     skyBox: {
            //         show: true
            //     }
            // })
            // const chartLayer = new global.DC.ChartLayer('busLayer').addTo(global.viewer)
            // chartLayer.setOption(that.busPathsInit())
            // global.viewer.scene.backgroundColor = global.DC.Namespace.Cesium.Color.fromBytes(245, 244, 238)
            // global.viewer.scene.backgroundColor = global.DC.Namespace.Cesium.Color.fromBytes(255, 255, 255)
            global.viewer.use(new global.DC.Weather())
            global.viewer.weather.cloud.enable = true
            global.viewer.weather.cloud.rotateAmount = 0.02
            // global.viewer.use(new global.DC.Weather())
            // global.viewer.weather.cloud.enable = true
            // global.viewer.weather.cloud.rotateAmount = 0.02
            that.$store.commit('SET_VIEWEREXIST', true)
@@ -259,14 +275,13 @@
                selectionIndicator: false,
                timeline: false,
                navigationHelpButton: false,
                navigationInstructionsInitiallyVisible: false,
                creditContainer: undefined
                navigationInstructionsInitiallyVisible: false
                // sceneMode: global.DC.Namespace.Cesium.SceneMode.SCENE2D
            })
            global.eagleViewer.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',
                    url: 'http://t{s}.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=e9533f5acb2ac470b07f406a4d24b4f0',
                    subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
                    format: 'image/jpeg',
                    show: true,
@@ -276,7 +291,7 @@
            global.eagleViewer.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',
                    url: 'http://t{s}.tianditu.gov.cn/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=e9533f5acb2ac470b07f406a4d24b4f0',
                    subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
                    format: 'image/jpeg',
                    show: true,
@@ -293,6 +308,30 @@
            var isLeftTrigger = false
            var isRightTrigger = false
            handlerL.setInputAction(function (movement) {
                that.startWheel = true
                if (movement > 0) {
                    // 向下
                    that.wheelFlag = true
                } else {
                    // 向上
                    that.wheelFlag = false
                }
            }, global.DC.Namespace.Cesium.ScreenSpaceEventType.WHEEL)
            handlerR.setInputAction(function (movement) {
                that.startSmallWheel = true
                if (that.samllMapFlag) {
                    if (movement > 0) {
                        // 向下
                        that.wheelFlag = true
                    } else {
                        // 向上
                        that.wheelFlag = false
                    }
                }
            }, global.DC.Namespace.Cesium.ScreenSpaceEventType.WHEEL)
            handlerL.setInputAction(function (movement) {
                isLeftTrigger = true
@@ -362,7 +401,7 @@
                // Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
                // fromDegrees()方法,将经纬度和高程转换为世界坐标
                destination: global.DC.Namespace.Cesium.Cartesian3.fromDegrees(
                    115.871863, 28.743861, 1400.0
                    116.35381525, 27.95839468, 1950.0
                ),
                orientation: {
                    // 指向
@@ -404,9 +443,7 @@
            //     })
            // })
            that.$refs.leftNav.initialize()
            // const key = '0f7c1d161d7352116a21aacf0e9f44c1'
            // const key = 'e9533f5acb2ac470b07f406a4d24b4f0'
            // const vec = global.DC.ImageryLayerFactory.createTdtImageryLayer({
            //     key
            // })
@@ -547,8 +584,13 @@
        }
        global.DC.ready(initViewer)
        that.$refs.leftNav.initialize()
    },
    methods: {
        changeWheel (val, type) {
            this[type] = val
        },
        mapClick (e) {
            this.$refs.campusNavRoute.shortcutShow(e)
            this.$refs.campusBuildingSearch.shortcutShow(e)
@@ -810,10 +852,8 @@
                var res = []
                for (var i = 0; i < data.length; i++) {
                    var dataItem = data[i]
                    //          console.log('dataItem',dataItem) //第二个数据
                    var fromCoord = [115.8716, 28.7436]
                    var toCoord = chinaGeoCoordMap[dataItem[0].name]
                    //          console.log('toCoord',toCoord);//第一个地址
                    if (fromCoord && toCoord) {
                        res.push([
                            {
@@ -880,7 +920,6 @@
                                    // color: '#f00'
                                    color: function (params) {
                                        // 圆环显示文字
                                        // console.log('redName',redName)
                                        return '#ffa022'
                                    },
@@ -901,7 +940,6 @@
                                extraCssText: 'z-index:100',
                                formatter: function (params, ticket, callback) {
                                    // 根据业务自己拓展要显示的内容
                                    // console.log('params--2',params)
                                    let res = ''
                                    const name = params.data.dataItem[0].name
                                    const price = params.data.dataItem[0].price
@@ -918,7 +956,6 @@
                                }
                            },
                            data: item[1].map(function (dataItem) {
                                //    console.log('dataItem',dataItem[0]);
                                return {
                                    dataItem: dataItem,
                                    name: dataItem[0].name,