1
guanqb
2023-03-16 9e3d41cca88b47afa2768697c9c41d66ca4463f4
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)
               }
        },
        // 修改标绘样式