1
guanqb
2023-03-16 9e3d41cca88b47afa2768697c9c41d66ca4463f4
1
2 files modified
138 ■■■■ changed files
src/views/activity/components/drawBtnBox.vue 121 ●●●● patch | view | raw | blame | history
src/views/activity/index.vue 17 ●●●●● patch | view | raw | blame | history
src/views/activity/components/drawBtnBox.vue
@@ -174,7 +174,7 @@
                        flag = true
                        overlay.on(global.DC.MouseEventType.CLICK, this.$parent.overlayTypeClick)
                        // overlay.on(global.DC.MouseEventType.CLICK, this.$parent.overlayTypeClick)
                        overlay.drawType = poltType
@@ -476,42 +476,109 @@
               })
            }
        },
        // 保存新增警力资源
        addNewPolice(data,type){
                let positionObj = this.$parent.convertBillboardPositionDate(data, type)
                let positionArr = data.position.slice(7, data.position.length - 2).split(',')[0].split(' ')
                let position = new global.DC.Position(Number(positionArr[0]), Number(positionArr[1]))
                let point = new global.DC.Point(position)
        addNewPolice(data,type,carType){
           // 巡逻路线添加
           if(type == 'policecar' && carType == 1) {
                console.log(data,666665);
                // 线坐标字符串
                let positionNewArr = this.$parent.convertPolylineOrPolygonPositionDate(data.position, data.type)
                positionNewArr = positionNewArr.slice(1,positionNewArr.length - 2)
                 // 范围面坐标串
                let coords = global.DC.GeoTools.polylineBuffer(positionNewArr, data.width != -1 ? data.width : 100)
                let positionStr = ''
                coords.forEach(item => {
                    positionStr += item[0] + ',' + item[1] + ';'
                })
                // 面颜色
                let color = ''
                // 线颜色
                let lineColor = ''
                if (data.color == '') {
                    color = global.DC.Namespace.Cesium.Color.fromBytes(255, 0, 0, 150)
                } else {
                    let r = parseInt(data.color.slice(1, 3), 16)
                    let g = parseInt(data.color.slice(3, 5), 16)
                    let b = parseInt(data.color.slice(5, 7), 16)
                    color = global.DC.Namespace.Cesium.Color.fromBytes(r, g, b, 255)
                    color = global.DC.Namespace.Cesium.Color.fromBytes(r, g, b, 150)
                    lineColor = global.DC.Namespace.Cesium.Color.fromBytes(r, g, b, 255)
                }
                point.attrParams = positionObj
                drawLayers.addOverlay(point)
                point.setStyle({
                    "color": color, //颜色
                    "outlineColor": color, //边框颜色
                    "outlineWidth": 0, //边框大小,
                    "pixelSize": 32,
                addPoliceIconOverlayData.setStyle({
                    "material": lineColor,
                    'width': 3
                })
                // point.on(global.DC.MouseEventType.CLICK, this.$parent.overlayTypeClick)
                point.on(global.DC.MouseEventType.MOUSE_OVER, this.$parent.pointMouseOver)
                point.on(global.DC.MouseEventType.MOUSE_OUT, this.$parent.pointMouseOut)
                addPoliceIconOverlayData.attrParams = positionObj
                addPoliceIconOverlayData.attrParams.pointOverlayData = point
                addPoliceIconOverlayData.position = {
                 lng: Number(positionArr[0]),
                 lat: Number(positionArr[1]),
                 alt: 0.5,
                }
                addPoliceIconOverlayData.on(global.DC.MouseEventType.CLICK, this.$parent.overlayTypeClick)
                // addPoliceIconOverlayData.on(global.DC.MouseEventType.MOUSE_OVER, this.$parent.pointMouseOver)
                addPoliceIconOverlayData.on(global.DC.MouseEventType.MOUSE_OUT, this.$parent.pointMouseOut)
                // let lineObj = new global.DC.Polyline(positionNewArr)
                // drawLayers.addOverlay(lineObj)
                // lineObj.setStyle({
                //     'material': lineColor,
                //     'width': 3
                // })
                data.linePositionStr = positionNewArr
                data.polygonPositionStr = positionStr
                data.lineObj = addPoliceIconOverlayData
                // this.$EventBus.$emit('layerPolygonAdd', {
                //     layerName: 'newCarDrawLineLayers',
                //     positions: positionStr,
                //     material: color,
                //     params: data,
                //     incident: this.lineOverlayTypeClick
                // })
                let areaPolygon = new global.DC.Polygon(positionStr)
                console.log('positionStr',positionStr);
                drawLayers.addOverlay(areaPolygon)
                areaPolygon.setStyle({
                    'material': lineColor,
                })
                areaPolygon.attrParams = data
                console.log('areaPolygon',areaPolygon);
                let lineObj = new global.DC.Polyline(positionNewArr)
                drawLayers.addOverlay(lineObj)
                lineObj.setStyle({
                    'material': global.DC.Namespace.Cesium.Color.fromBytes(255, 0, 0, 150),
                    'width': 30
                })
           }else{
               let positionObj = this.$parent.convertBillboardPositionDate(data, type)
               let positionArr = data.position.slice(7, data.position.length - 2).split(',')[0].split(' ')
               let position = new global.DC.Position(Number(positionArr[0]), Number(positionArr[1]))
               let point = new global.DC.Point(position)
               let color = ''
               if (data.color == '') {
                   color = global.DC.Namespace.Cesium.Color.fromBytes(255, 0, 0, 150)
               } else {
                   let r = parseInt(data.color.slice(1, 3), 16)
                   let g = parseInt(data.color.slice(3, 5), 16)
                   let b = parseInt(data.color.slice(5, 7), 16)
                   color = global.DC.Namespace.Cesium.Color.fromBytes(r, g, b, 255)
               }
               point.attrParams = positionObj
               drawLayers.addOverlay(point)
               point.setStyle({
                   "color": color, //颜色
                   "outlineColor": color, //边框颜色
                   "outlineWidth": 0, //边框大小,
                   "pixelSize": 32,
               })
               // point.on(global.DC.MouseEventType.CLICK, this.$parent.overlayTypeClick)
               point.on(global.DC.MouseEventType.MOUSE_OVER, this.$parent.pointMouseOver)
               point.on(global.DC.MouseEventType.MOUSE_OUT, this.$parent.pointMouseOut)
               addPoliceIconOverlayData.attrParams = positionObj
               addPoliceIconOverlayData.attrParams.pointOverlayData = point
               addPoliceIconOverlayData.position = {
                lng: Number(positionArr[0]),
                lat: Number(positionArr[1]),
                alt: 0.5,
               }
               addPoliceIconOverlayData.on(global.DC.MouseEventType.CLICK, this.$parent.overlayTypeClick)
               // addPoliceIconOverlayData.on(global.DC.MouseEventType.MOUSE_OVER, this.$parent.pointMouseOver)
               addPoliceIconOverlayData.on(global.DC.MouseEventType.MOUSE_OUT, this.$parent.pointMouseOut)
               }
        },
        // 修改标绘样式
src/views/activity/index.vue
@@ -992,9 +992,7 @@
         * @return {*}
         */
        addMapLineLayers (data) {
            console.log('data',data);
            data.forEach(item => {
                console.log('item',item);
                let positionNewArr = this.convertPolylineOrPolygonPositionDate(item.position, item.type)
                // 线坐标字符串
                item.linePositionStr = positionNewArr
@@ -1143,7 +1141,7 @@
        addCarAndRange (params) {
            addCarAndRange(params).then(res => {
                if (res.data.success) {
                    this.$refs.DRAWBTNBOX.addNewPolice(res.data.data,'policeman')
                    this.$refs.DRAWBTNBOX.addNewPolice(res.data.data,'policecar',params.type)
                    this.$message({
                        message: '添加成功',
                        type: 'success'
@@ -1162,7 +1160,7 @@
        addActivityPolice (params) {
            addActivityPolice(params).then(res => {
                if (res.data.success) {
                    this.$refs.DRAWBTNBOX.addNewPolice(res.data.data, 'policecar')
                    this.$refs.DRAWBTNBOX.addNewPolice(res.data.data, 'policeman')
                    this.$message({
                        message: '添加成功',
                        type: 'success'
@@ -1462,7 +1460,7 @@
        cancelSaveLine () {
            this.lineEditVisible = false
            this.$refs.DRAWBTNBOX.removeDraw()
            // this.$refs.DRAWBTNBOX.removeDraw()
        },
        // 巡逻路线面点击事件
@@ -1639,14 +1637,14 @@
        deleteActivityCar (id, type) {
            deleteActivityCar(id).then(res => {
                if (res.data.success) {
                    policeOverlayData.overlay.remove()
                    if('pointOverlayData' in policeOverlayData.overlay.attrParams){
                        policeOverlayData.overlay.attrParams.pointOverlayData.remove()
                    }
                    this.$message({
                        message: '删除成功',
                        type: 'success'
                    })
                    policeOverlayData.overlay.remove()
                    if('pointOverlayData' in policeOverlayData.overlay.attrParams){
                        policeOverlayData.overlay.attrParams.pointOverlayData.remove()
                    }
                } else {
                    this.$message({
                        message: '删除失败',
@@ -1675,7 +1673,6 @@
                        type: 'error'
                    })
                }
                // this.getSecurityPoliceList(this.showingSecurityId, this.policeSwitch)
            })
        },