src/components/map/index.vue
@@ -81,6 +81,8 @@
    sdTilesetLayer: null
}
let flootEntitysEntites = null
import mapPopup from './components/mapPopup.vue'
export default {
@@ -243,10 +245,10 @@
                console.log(e, 989999)
            })
            let positions = [[117.9514788, 28.4478968, 0], [117.9514698, 28.4478947, 0], [117.9513974, 28.4476981, 0], [117.9515047, 28.4476748, 0], [117.9515289, 28.4476939, 0], [117.9515508, 28.447755, 0], [117.9516278, 28.4477353, 0], [117.9516623, 28.4478497, 0], [117.9514788, 28.4478968, 0]]
            // let positions = [[117.9514788, 28.4478968, 0], [117.9514698, 28.4478947, 0], [117.9513974, 28.4476981, 0], [117.9515047, 28.4476748, 0], [117.9515289, 28.4476939, 0], [117.9515508, 28.447755, 0], [117.9516278, 28.4477353, 0], [117.9516623, 28.4478497, 0], [117.9514788, 28.4478968, 0]]
            // let positions = [[117.951478782, 28.447896798, 0], [117.951469798, 28.447894686, 0], [117.951397357, 28.447698099, 0], [117.951505114, 28.447674695, 0], [117.951485465, 28.447619271, 0], [117.951706955, 28.447558541, 0], [117.951722755, 28.447611995, 0], [117.951834021, 28.447588427, 0], [117.951896863, 28.447789523, 0], [117.951478782, 28.447896798, 0]]
            let positions = [[117.951478782, 28.447896798, 0], [117.951469798, 28.447894686, 0], [117.951397357, 28.447698099, 0], [117.951505114, 28.447674695, 0], [117.951485465, 28.447619271, 0], [117.951706955, 28.447558541, 0], [117.951722755, 28.447611995, 0], [117.951834021, 28.447588427, 0], [117.951896863, 28.447789523, 0], [117.951478782, 28.447896798, 0]]
            let MIN_F_H = positions.map(item => {
                item[2] = 70
                return item
@@ -260,25 +262,29 @@
            // 原生Cesium加载多边体
            let floorEntitysLayers = new global.DC.Namespace.Cesium.CustomDataSource("floorEntitysLayers")
            global.viewer.dataSources.add(floorEntitysLayers)
            let flootEntitysEntites = floorEntitysLayers.entities
            flootEntitysEntites = floorEntitysLayers.entities
            let floorPositions = positions.reduce((prev, curr, index, arr) => {
                curr.forEach(item => {
                    prev.push(item)
                })
                return prev
            }, [])
            // let floorPositions = positions.reduce((prev, curr, index, arr) => {
            //     curr.forEach(item => {
            //         prev.push(item)
            //     })
            //     return prev
            // }, [])
            flootEntitysEntites.add({
                polygon: {
                    hierarchy: global.DC.Namespace.Cesium.Cartesian3.fromDegreesArrayHeights(floorPositions),
                    heightReference: global.DC.Namespace.Cesium.HeightReference.RELATIVE_TO_GROUND,
                    extrudedHeightReference: global.DC.Namespace.Cesium.HeightReference.RELATIVE_TO_GROUND,
                    height: 70,
                    extrudedHeight: 80,
                    material: global.DC.Namespace.Cesium.Color.RED.withAlpha(0.5),
                }
            })
            // flootEntitysEntites.add({
            //     polygon: {
            //         hierarchy: global.DC.Namespace.Cesium.Cartesian3.fromDegreesArrayHeights(floorPositions),
            //         heightReference: global.DC.Namespace.Cesium.HeightReference.RELATIVE_TO_GROUND,
            //         extrudedHeightReference: global.DC.Namespace.Cesium.HeightReference.RELATIVE_TO_GROUND,
            //         height: 70,
            //         extrudedHeight: 80,
            //         material: global.DC.Namespace.Cesium.Color.RED.withAlpha(0.5),
            //     }
            // })
            // console.log(floorPositions)
@@ -401,6 +407,14 @@
            that.flytoLayer(params.polygonName, params.duration)
        })
        this.$EventBus.$on('showHouse3D', (params) => {
            that.showHouse3D(params.positions, params.minHeight, params.maxHeight)
        })
        this.$EventBus.$on('clearHouse3D', () => {
            that.clearHouse3D()
        })
        // 重写定位方法
        const homeCenter = [117.99311892441567, 28.46938164123123]
        this.$nextTick(() => {
@@ -424,6 +438,7 @@
                this.$router.push({ path: '/layout/house', query: { searchName: 'xxx小区' } })
            }
        },
        switchImg () {
            // 天地图 影像
            this.imgtype = 0
@@ -439,6 +454,7 @@
            )
            this.showImgBtn = false
        },
        switchElec () {
            // 天地图 矢量
            this.imgtype = 1
@@ -454,6 +470,7 @@
            )
            this.showImgBtn = false
        },
        /**
         * @description: 全屏控制
         * @return {*} 无返回值
@@ -486,6 +503,7 @@
                this.isFullscreen = true
            }
        },
        /**
         * 在图层中添加实体(点)
         * @param {*} item 图标
@@ -732,6 +750,39 @@
                tilesetObject[titlesetName] = null
            }
        },
        /**
        * 建筑高亮显示
        * @param {*} positions 建筑范围坐标
        * @param {*}
        */
        showHouse3D (positions, minHeight, maxHeight) {
            flootEntitysEntites.removeAll()
            let housePositions = JSON.parse(positions).coordinates[0]
            let floorPositions = housePositions.reduce((prev, curr) => {
                curr.forEach(item => {
                    prev.push(item)
                })
                return prev
            }, [])
            flootEntitysEntites.add({
                polygon: {
                    hierarchy: global.DC.Namespace.Cesium.Cartesian3.fromDegreesArrayHeights(floorPositions),
                    heightReference: global.DC.Namespace.Cesium.HeightReference.RELATIVE_TO_GROUND,
                    extrudedHeightReference: global.DC.Namespace.Cesium.HeightReference.RELATIVE_TO_GROUND,
                    height: minHeight,
                    extrudedHeight: maxHeight,
                    material: global.DC.Namespace.Cesium.Color.RED.withAlpha(0.5),
                }
            })
        },
        // 清除建筑3D
        clearHouse3D () {
            flootEntitysEntites.removeAll()
        },
    },
}