guanqb
2022-10-25 b9aead3b741cd6cd84b3198869fa6149d1c9d0c8
Merge branch 'master' of http://192.168.0.105:10010/r/srs-police-affairs
3 files modified
135 ■■■■ changed files
src/utils/EntityDraw.js 115 ●●●● patch | view | raw | blame | history
src/views/lyout/index.vue 9 ●●●● patch | view | raw | blame | history
src/views/video/index.vue 11 ●●●●● patch | view | raw | blame | history
src/utils/EntityDraw.js
@@ -2,7 +2,7 @@
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2022-10-18 17:17:50
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2022-10-20 10:10:26
 * @LastEditTime: 2022-10-25 16:38:11
 * @FilePath: \srs-police-affairs\src\utils\EntityDraw.js
 * @Description: 
 * 
@@ -12,6 +12,7 @@
export default class EntityDraw {
    drawPolygonLayer = null
    drawPolylineLayer = null
    drawPointLayer = null
@@ -20,6 +21,8 @@
    activeShape = null
    drawCompletePosition = []
    type = ''
    constructor() {
        // 去除双击
@@ -39,12 +42,19 @@
        this.drawPolygonLayer = new global.DC.VectorLayer('drawPolygonLayer')
        global.viewer.addLayer(this.drawPolygonLayer)
        // 添加线图层
        this.drawPolylineLayer = new global.DC.VectorLayer('drawPolylineLayer')
        global.viewer.addLayer(this.drawPolylineLayer)
        // 添加点图层
        this.drawPointLayer = new global.DC.VectorLayer('drawPointLayer')
        global.viewer.addLayer(this.drawPointLayer)
    }
    activate () {
    activate (type) {
        this.type = type
        this.drawCompletePosition = []
        this.clearLayer()
@@ -83,14 +93,27 @@
    drawGraph (positionData) {
        let graph
        graph = global.viewer.entities.add({
            polygon: {
                hierarchy: positionData,
                material: new global.DC.Namespace.Cesium.ColorMaterialProperty(
                    global.DC.Namespace.Cesium.Color.NAVAJOWHITE.withAlpha(0.7)
                ),
            }
        })
        if (this.type === "polyline") {
            graph = global.viewer.entities.add({
                polyline: {
                    material: new global.DC.Namespace.Cesium.ColorMaterialProperty(
                        global.DC.Namespace.Cesium.Color.NAVAJOWHITE.withAlpha(0.7)
                    ),
                    positions: positionData,
                    clampToGround: true,
                    width: 3,
                },
            })
        } else {
            graph = global.viewer.entities.add({
                polygon: {
                    hierarchy: positionData,
                    material: new global.DC.Namespace.Cesium.ColorMaterialProperty(
                        global.DC.Namespace.Cesium.Color.NAVAJOWHITE.withAlpha(0.7)
                    ),
                }
            })
        }
        return graph
    }
@@ -118,7 +141,13 @@
            that.activeShapePoints.push(event.surfacePosition)
            const dynamicPositions = new global.DC.Namespace.Cesium.CallbackProperty(function () {
                return new global.DC.Namespace.Cesium.PolygonHierarchy(that.activeShapePoints)
                if (that.type === "polyline") {
                    return that.activeShapePoints
                } else {
                    return new global.DC.Namespace.Cesium.PolygonHierarchy(that.activeShapePoints)
                }
            }, false)
            that.activeShape = that.drawGraph(dynamicPositions)
@@ -149,10 +178,19 @@
    }
    rightEvent (event) {
        if (this.activeShapePoints.length < 4) {
            global.viewer.tooltip.showAt(event.windowPosition, '不能绘制成面,请继续添加点')
            return
        if (this.type === "polyline") {
            if (this.activeShapePoints.length < 2) {
                global.viewer.tooltip.showAt(event.windowPosition, '不能绘制成线,请继续添加点')
                return
            }
        } else {
            if (this.activeShapePoints.length < 4) {
                global.viewer.tooltip.showAt(event.windowPosition, '不能绘制成面,请继续添加点')
                return
            }
        }
        this.terminateShape()
    }
@@ -169,15 +207,31 @@
        })
        let polygon = new global.DC.Polygon(this.drawCompletePosition)
        if (this.type === "polyline") {
        polygon.setStyle({
            material: new global.DC.Namespace.Cesium.ColorMaterialProperty(
                global.DC.Namespace.Cesium.Color.NAVAJOWHITE.withAlpha(0.7)
            )
        })
            let polyline = new global.DC.Polyline(this.drawCompletePosition)
        this.drawPolygonLayer.addOverlay(polygon)
            polyline.setStyle({
                material: new global.DC.Namespace.Cesium.ColorMaterialProperty(
                    global.DC.Namespace.Cesium.Color.NAVAJOWHITE.withAlpha(0.7)
                )
            })
            this.drawPolylineLayer.addOverlay(polyline)
        } else {
            let polygon = new global.DC.Polygon(this.drawCompletePosition)
            polygon.setStyle({
                material: new global.DC.Namespace.Cesium.ColorMaterialProperty(
                    global.DC.Namespace.Cesium.Color.NAVAJOWHITE.withAlpha(0.7)
                )
            })
            this.drawPolygonLayer.addOverlay(polygon)
        }
        this.clickInTheProcess()
    }
@@ -200,5 +254,24 @@
    // 清除
    clearLayer () {
        this.drawPolygonLayer.clear()
        this.drawPolylineLayer.clear()
    }
    // 销毁
    destroy () {
        this.unRegisterEvents()
        this.drawPolygonLayer.clear()
        this.drawPolygonLayer.remove()
        this.drawPolylineLayer.clear()
        this.drawPolylineLayer.remove()
        this.drawPointLayer.clear()
        this.drawPointLayer.remove()
        this.activeShape = null
        this.activeShapePoints = []
        this.drawCompletePosition = []
    }
}
src/views/lyout/index.vue
@@ -2,7 +2,7 @@
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2022-08-18 16:18:24
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2022-09-26 16:58:48
 * @LastEditTime: 2022-10-25 16:42:04
 * @FilePath: \srs-police-affairs\src\views\lyout\index.vue
 * @Description: 
 * 
@@ -82,6 +82,12 @@
        this.currentUrl = this.$route.path
    },
    watch: {
        $route (to, from) {
            this.currentUrl = to.path
        }
    },
    mounted () {
    },
@@ -95,7 +101,6 @@
        goToPath (params) {
            if (params.path) {
                if (this.$route.path == params.path) return
                this.currentUrl = params.path
                this.$router.push(params.path)
            } else {
                params.childrenFlag = !params.childrenFlag
src/views/video/index.vue
@@ -2,7 +2,7 @@
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2022-08-18 16:18:17
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2022-10-19 15:22:24
 * @LastEditTime: 2022-10-25 15:40:54
 * @FilePath: \srs-police-affairs\src\views\video\index.vue
 * @Description: 辖区管理
 * 
@@ -17,7 +17,8 @@
        </div>
        <div class="draw-btn">
            <button @click="draw">绘制</button>
            <button @click="draw('polygon')">绘制面</button>
            <button @click="draw('polyline')">绘制线</button>
            <button @click="removeDrawLayer">清除</button>
        </div>
@@ -190,8 +191,8 @@
            this.monitoringList = [item]
        },
        draw () {
            graphicLayer.activate()
        draw (type) {
            graphicLayer.activate(type)
        },
        removeDrawLayer () {
@@ -205,6 +206,8 @@
            layerName: 'monitoringLayers',
            type: 'VectorLayer'
        })
        graphicLayer.destroy()
    }
}
</script>