guanqb
2022-11-07 adcdf0d9f2e37b9719d63113d2ae1a9d698ef20e
热区效果添加
2 files modified
65 ■■■■ changed files
src/components/map/index.vue 27 ●●●●● patch | view | raw | blame | history
src/views/activity/index.vue 38 ●●●●● patch | view | raw | blame | history
src/components/map/index.vue
@@ -244,7 +244,6 @@
        this.$EventBus.$on('layerPointAdd', (params) => {
            // eslint-disable-next-line no-unused-vars
            // console.log(params.incident)
            that.layerPointAdd(params.layerName, params.type, params.layerType, params.params, params.distanceDisplayCondition, params.incident)
        })
@@ -291,7 +290,6 @@
            // 最新写法
            const isFullScreen = document.fullscreenElement
            if (isFullScreen) {
                console.log('退出全屏')
                if (document.exitFullscreen) {
                    document.exitFullscreen()
                } else if (document.msExitFullscreen) {
@@ -304,7 +302,6 @@
                this.isFullscreen = false
            } else {
                var fullscreen = document.body   // 需要全屏的元素
                console.log('进入全屏')
                if (fullscreen.requestFullscreen) {
                    fullscreen.requestFullscreen()
                } else if (fullscreen.mozRequestFullScreen) {
@@ -348,6 +345,12 @@
                layersObjcect[layerName] = new global.DC.ClusterLayer(layerName)
                layersObjcect[layerName].addTo(global.viewer)
            } else if (type == 'HeatLayer') {
                if (!layersObjcect[layerName]) layersObjcect[layerName] = null
                layersObjcect[layerName] = new global.DC.HeatLayer(layerName)
                layersObjcect[layerName].addTo(global.viewer)
            }
        },
@@ -357,7 +360,7 @@
         * @param {*} type 图层类型
         */
        mapRemoveLayer (layerName, type) {
            if (type == 'VectorLayer' || type == 'ClusterLayer') {
            if (type == 'VectorLayer' || type == 'ClusterLayer' || type == 'HeatLayer') {
                if (layersObjcect[layerName] && layersObjcect[layerName] != null) {
                    layersObjcect[layerName].remove()
                    layersObjcect[layerName] = null
@@ -371,7 +374,7 @@
         * @param {*} type 图层类型
         */
        mapClearLayer (layerName, type) {
            if (type == 'VectorLayer' || type == 'ClusterLayer') {
            if (type == 'VectorLayer' || type == 'ClusterLayer' || type == 'HeatLayer') {
                if (layersObjcect[layerName] && layersObjcect[layerName] != null)
                    layersObjcect[layerName].clear()
            }
@@ -397,11 +400,12 @@
            if (type == "billboard") {
                pointElement = new global.DC.Billboard(new global.DC.Position(Number(params.lng), Number(params.lat), Number(params.alt)), params.url)
                pointElement.size = [32, 32]
                pointElement.attrParams = params
                layersObjcect[layerName].addOverlay(pointElement)
                pointElement.on(global.DC.MouseEventType.CLICK, incident)
            } else if (type == "label") {
                pointElement = new global.DC.Label(new global.DC.Position(Number(params.lng), Number(params.lat), Number(params.alt)), params.text)
                pointElement.setStyle({
                    fillColor: global.DC.Color.CRIMSON,
                    style: global.DC.Namespace.Cesium.LabelStyle.FILL_AND_OUTLINE,
@@ -411,13 +415,14 @@
                    pixelOffset: { x: 0, y: -24 },
                    distanceDisplayCondition: distanceDisplayCondition
                })
            }
            pointElement.attrParams = params
            layersObjcect[layerName].addOverlay(pointElement)
            pointElement.on(global.DC.MouseEventType.CLICK, incident)
            } else if (type == 'HeatPoint') {
                layersObjcect[layerName].setPositions(params.positions)
            }
        },
        /**
src/views/activity/index.vue
@@ -397,6 +397,10 @@
                        lat: 28.684435,
                        alt: 100,
                    }]
                },
                {
                    id: 777,
                    label: '热力图'
                }]
            }],
            defaultProps: {
@@ -490,7 +494,34 @@
    updated () { },
    methods: {
        generatePosition (num) {
            let list = []
            for (let i = 0; i < num; i++) {
                let lng = 115.974 + Math.random() * 0.5
                let lat = 28.628 + Math.random() * 0.5
                list.push(new global.DC.Position(lng, lat))
            }
            return list
        },
        treeCheckClick (e1, e2) {
            const that = this
            this.$EventBus.$emit('mapRemoveLayer', {
                layerName: 'activeHeatLayer',
                type: 'HeatLayer'
            })
            if (e1.label == '热力图' && e2.checkedKeys.some(item => {
                return item == 777
            })) {
                this.$EventBus.$emit('layerPointAdd', {
                    layerName: 'activeHeatLayer',
                    type: "HeatPoint",
                    layerType: 'HeatLayer',
                    params: {
                        positions: that.generatePosition(2000)
                    }
                })
            } else {
            this.$EventBus.$emit('mapClearLayer', {
                layerName: 'activeLayer',
                type: 'VectorLayer'
@@ -505,6 +536,7 @@
                    })
                }
            })
            }
        },
        treeNodeClick () {
@@ -513,7 +545,7 @@
                100
            )
            this.$EventBus.$emit('layerPolylineAdd', {
                layerName: 'polylineLayer',
                layerName: 'polylineLayer1',
                positions: '116.025000, 28.686000, 116.025000, 28.678000,116.020000, 28.678000',
                material: color,
                width: 2
@@ -668,6 +700,10 @@
            layerName: 'polylineLayer',
            type: 'VectorLayer'
        })
        this.$EventBus.$emit('mapRemoveLayer', {
            layerName: 'activeHeatLayer',
            type: 'HeatLayer'
        })
        analyseLayer.clear()