jxdnsong
2023-04-05 d5eece86c4754bf20d540339477209d23c2d7b4c
src/components/map/index.vue
@@ -2,7 +2,7 @@
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2022-08-18 17:00:30
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2023-04-04 18:18:42
 * @LastEditTime: 2023-04-05 00:50:03
 * @FilePath: \srs-police-affairs\src\components\map\index.vue
 * @Description: 公用地图组件
 * 
@@ -249,6 +249,9 @@
            global.viewer.addLayer(layersObjcect.monitoringLayer)
            layersObjcect.panoramaLayer = new global.DC.VectorLayer('panoramaLayer')
            global.viewer.addLayer(layersObjcect.panoramaLayer)
            floorEntitysLayers = new global.DC.VectorLayer('floorEntitysLayers')
            global.viewer.addLayer(floorEntitysLayers)
            // 模型图层添加
            tilesetLayer = new global.DC.TilesetLayer('tilesetLayer')
@@ -608,7 +611,7 @@
            })
            // this.addMxTileset('sdTilesetLayer', `${tile3DUrl}/sf3d/361102/model/wanda/tileset.json`)
            // this.addMxTileset('sdTilesetLayer', `https://tuan-gis.sit.fengtu.com.cn/361102/wanda/tileset.json`)
            // this.addMxTileset('sdTilesetLayer02', `https://tuan-gis.sit.fengtu.com.cn/361102/wanda/tileset.json`)
            // this.addMxTileset('sdTilesetLayer', `/mx/01/tileset.json`)
            if (this.tilesetLayerType == type && status == '') {
@@ -744,7 +747,7 @@
         * @param {*} layerName 图层名称
         * @param {*} type 图层类型
         */
        mapAddLayer (layerName, type) {
        mapAddLayer (layerName, type, ClusterLayerType) {
            if (type == 'VectorLayer') {
                if (!layersObjcect[layerName]) layersObjcect[layerName] = null
@@ -753,9 +756,8 @@
                layersObjcect[layerName].addTo(global.viewer)
            } else if (type == 'ClusterLayer') {
                if (!layersObjcect[layerName]) layersObjcect[layerName] = null
                layersObjcect[layerName] = new global.DC.ClusterLayer(layerName, {
                    pixelRange: 40
                    pixelRange: 40, style: ClusterLayerType
                })
                layersObjcect[layerName].addTo(global.viewer)
@@ -831,7 +833,7 @@
            far: Number.MAX_VALUE //最远距离
        }, incident = (e) => { }, mouseOverIncident = (e) => { }, mouseOutIncident = (e) => { }, pointMouseMove = (e) => { }) {
            if (!layersObjcect[layerName] || layersObjcect[layerName] == null) {
                this.mapAddLayer(layerName, layerType)
                this.mapAddLayer(layerName, layerType, params.ClusterLayerType)
            }
            let pointElement
@@ -844,6 +846,7 @@
                pointElement = new global.DC.Billboard(new global.DC.Position(Number(params.lng), Number(params.lat), 4), params.url)
                pointElement.setStyle(params.setStyle)
                pointElement.size = [32, 32]
                pointElement.style = "clustering"
                pointElement.attrParams = params
                layersObjcect[layerName].addOverlay(pointElement)
                pointElement.on(global.DC.MouseEventType.CLICK, incident)
@@ -1116,43 +1119,42 @@
        * @param {*} 
        */
        showThreeDimensions (positions, minHeight, maxHeight) {
            if (flootEntitysEntites == null) {
                floorEntitysLayers = new global.DC.Namespace.Cesium.CustomDataSource("floorEntitysLayers")
                global.viewer.dataSources.add(floorEntitysLayers)
                flootEntitysEntites = floorEntitysLayers.entities
            } else {
                flootEntitysEntites.removeAll()
            if (floorEntitysLayers != null) {
                floorEntitysLayers.remove()
                floorEntitysLayers = new global.DC.VectorLayer('floorEntitysLayers')
                global.viewer.addLayer(floorEntitysLayers)
            }
            floorEntitysLayers.clear()
            let housePositions = JSON.parse(positions).coordinates[0]
            let floorPositions = housePositions.reduce((prev, curr) => {
                curr.forEach(item => {
                    prev.push(item)
                })
                prev.push([curr[0], curr[1]])
                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),
                }
            let polygonStr = floorPositions.join(';')
            let polygon = new global.DC.Polygon(polygonStr)
            polygon.setStyle({
                material: global.DC.Namespace.Cesium.Color.RED.withAlpha(0.5),
                extrudedHeight: maxHeight,
                height: minHeight,
                extrudedHeightReference: global.DC.Namespace.Cesium.HeightReference.RELATIVE_TO_GROUND,
                heightReference: global.DC.Namespace.Cesium.HeightReference.RELATIVE_TO_GROUND
            })
            floorEntitysLayers.addOverlay(polygon)
            floorEntitysLayers.show = true
        },
        // 清除建筑3D
        clearHouse3D () {
            if (flootEntitysEntites == null) {
                floorEntitysLayers = new global.DC.Namespace.Cesium.CustomDataSource("floorEntitysLayers")
                global.viewer.dataSources.add(floorEntitysLayers)
                flootEntitysEntites = floorEntitysLayers.entities
            } else {
                flootEntitysEntites.removeAll()
            }
            floorEntitysLayers.clear()
        },
    },