guanqb
2022-09-27 515c3c0424e5012f8bdc3adda9f4830e0b29d825
派出所地图名称添加
3 files modified
260 ■■■■ changed files
src/components/map/index.vue 15 ●●●● patch | view | raw | blame | history
src/components/select/index.vue 9 ●●●●● patch | view | raw | blame | history
src/views/home/index.vue 236 ●●●● patch | view | raw | blame | history
src/components/map/index.vue
@@ -245,7 +245,7 @@
        this.$EventBus.$on('layerPointAdd', (params) => {
            // eslint-disable-next-line no-unused-vars
            // console.log(params.incident)
            that.layerPointAdd(params.layerName, params.type, params.params, params.incident)
            that.layerPointAdd(params.layerName, params.type, params.params, params.distanceDisplayCondition, params.incident)
        })
        this.$EventBus.$on('layerPolygonAdd', (params) => {
@@ -331,10 +331,6 @@
            siteEntitylayers.addOverlay(billboard)
        },
        test () {
            console.log('map.test(MAP)!!!')
        },
        /**
         * 添加图层
         * @param {*} layerName 图层名称
@@ -382,7 +378,10 @@
         * @param {*} params 添加的点位参数(内容、详情)
         * @param {*} incident 添加的点位事件
         */
        layerPointAdd (layerName, type, params, incident = (e) => { }) {
        layerPointAdd (layerName, type, params, distanceDisplayCondition = {
            near: 0, //最近距离
            far: Number.MAX_VALUE //最远距离
        }, incident = (e) => { }) {
            if (!layersObjcect[layerName] || layersObjcect[layerName] == null) {
                this.mapAddLayer(layerName, 'VectorLayer')
            }
@@ -402,8 +401,10 @@
                    outlineColor: global.DC.Color.WHITE, // 边框颜色
                    outlineWidth: 4, // 边框大小,
                    font: '16px sans-serif',
                    pixelOffset: { x: 0, y: -24 }
                    pixelOffset: { x: 0, y: -24 },
                    distanceDisplayCondition: distanceDisplayCondition
                })
            }
            pointElement.attrParams = params
src/components/select/index.vue
@@ -20,8 +20,7 @@
                @click="cutValue(item, index)"
                v-for="(item, index) in options"
                :key="index"
                v-text="item.name"
            ></div>
            >{{item[optionsName]}}</div>
        </div>
    </div>
</template>
@@ -39,7 +38,11 @@
        checkValue: {
            type: String,
            required: true //必传
        }
        },
        optionsName: {
            type: String,
        },
    },
    data () {
src/views/home/index.vue
@@ -121,6 +121,7 @@
                @selectCheck="policeStationSelect"
                :checkValue="policeStationCheckValue"
                :options="policeStationOptions"
                :optionsName="'policeStationName'"
            ></map-select>
            <map-select
@@ -267,39 +268,138 @@
            //下拉框的内容 (Array类型) 必传
            policeStationOptions: [
                {
                    name: '全部'
                    policeStationName: '全部'
                },
                {
                    name: '车站派出所'
                    policeStationName: '车站派出所',
                    policeStationId: 1,
                    position: [
                        [115.935114, 28.627012, 0],
                        [115.930150, 28.733535, 0],
                        [115.986738, 28.683523, 0],
                        [116.015526, 28.647454, 0],
                    ]
                },
                {
                    name: '沙溪派出所'
                    policeStationName: '沙溪派出所',
                    policeStationId: 2,
                    position: [
                        [115.935114, 28.627012, 0],
                        [116.015526, 28.647454, 0],
                        [116.080062, 28.590419, 0],
                        [116.075505, 28.528672, 0],
                        [115.959503, 28.530546, 0],
                    ]
                },
                {
                    name: '灵溪派出所'
                    policeStationName: '灵溪派出所',
                    policeStationId: 3,
                    position: [
                        [116.080062, 28.590419, 0],
                        [116.075505, 28.528672, 0],
                        [116.167934, 28.527504, 0],
                        [116.346666, 28.615709, 0],
                    ]
                },
                {
                    name: '北门派出所'
                    policeStationName: '北门派出所',
                    policeStationId: 4,
                    position: [
                        [116.015526, 28.647454, 0],
                        [116.080062, 28.590419, 0],
                        [116.346666, 28.615709, 0],
                        [116.285670, 28.732610, 0],
                    ]
                },
                {
                    name: '江光派出所'
                    policeStationName: '江光派出所',
                    policeStationId: 5,
                    position: [
                        [116.015526, 28.647454, 0],
                        [116.285670, 28.732610, 0],
                        [116.085312, 28.807226, 0],
                        [115.930150, 28.733535, 0],
                        [115.986738, 28.683523, 0]
                    ]
                },
                {
                    name: '水南派出所'
                },
                {
                    name: '秦峰派出所'
                },
                {
                    name: '茅家岭派出所'
                },
                {
                    name: '西市派出所'
                },
                {
                    name: '朝阳派出所'
                }
                // {
                //     name: '水南派出所'
                // },
                // {
                //     name: '秦峰派出所'
                // },
                // {
                //     name: '茅家岭派出所'
                // },
                // {
                //     name: '西市派出所'
                // },
                // {
                //     name: '朝阳派出所'
                // }
            ],
            areaCheckoptions: [
                {
                    policeStationId: 1,
                    areaCheckId: 101,
                    areaCheckname: '责任区1',
                    position: [
                        [116.015526, 28.647454, 0],
                        [116.285670, 28.732610, 0],
                        [116.146022, 28.726446, 0],
                        [116.063119, 28.708172, 0]
                    ]
                },
                {
                    policeStationId: 1,
                    areaCheckId: 102,
                    areaCheckname: '责任区2',
                    position: [
                        [116.285670, 28.732610, 0],
                        [116.085312, 28.807226, 0],
                        [116.071504, 28.750699, 0],
                        [116.146022, 28.726446, 0],
                    ]
                },
                {
                    policeStationId: 1,
                    areaCheckId: 103,
                    areaCheckname: '责任区3',
                    position: [
                        [116.085312, 28.807226, 0],
                        [115.930150, 28.733535, 0],
                        [116.045446, 28.729623, 0],
                        [116.071504, 28.750699, 0]
                    ]
                },
                {
                    policeStationId: 1,
                    areaCheckId: 104,
                    areaCheckname: '责任区4',
                    position: [
                        [115.930150, 28.733535, 0],
                        [115.986738, 28.683523, 0],
                        [116.015526, 28.647454, 0],
                        [116.063119, 28.708172, 0],
                        [116.045446, 28.729623, 0]
                    ]
                },
                {
                    policeStationId: 1,
                    areaCheckId: 105,
                    areaCheckname: '责任区5',
                    position: [
                        [116.045446, 28.729623, 0],
                        [116.063119, 28.708172, 0],
                        [116.146022, 28.726446, 0],
                        [116.071504, 28.750699, 0]
                    ]
                }],
            areaOptions: [],
            housingOptions: []
        }
@@ -419,51 +519,69 @@
            cylinderLayer = new global.DC.PrimitiveLayer('cylinderLayer')
            global.viewer.addLayer(cylinderLayer)
            // position.forEach((item, index) => {
            this.policeStationOptions.forEach((item, index) => {
                if (item.position) {
                    let str = ''
                    item.position.forEach(it => {
                        str = str + `${it[0]},${it[1]},${it[2]};`
                    })
                    this.$EventBus.$emit('layerPolygonAdd', {
                        layerName: 'polygonLayer',
                        positions: str,
                        material: positionColor[index],
                        distanceDisplayCondition: {
                            near: 20000, //最近距离
                            far: Number.MAX_VALUE //最远距离
                        }
                    })
            position.forEach((item, index) => {
                    const center = this.getCenter(item.position)
                let str = ''
                item.forEach(it => {
                    str = str + `${it[0]},${it[1]},${it[2]};`
                })
                    this.$EventBus.$emit('layerPointAdd', {
                        layerName: 'homePersonLayer',
                        type: 'label',
                        params: {
                            lng: center[0],
                            lat: center[1],
                            alt: 1200,
                            text: '5656'
                        }
                    })
                this.$EventBus.$emit('layerPolygonAdd', {
                    layerName: 'polygonLayer',
                    positions: str,
                    material: positionColor[index],
                    distanceDisplayCondition: {
                        near: 20000, //最近距离
                        far: Number.MAX_VALUE //最远距离
                    }
                })
                    let titleLng = center[0] - 0.01
                    let titleLat = center[1] - 0.03
                    this.$EventBus.$emit('layerPointAdd', {
                        layerName: 'homePersonLayer',
                        type: 'label',
                        params: {
                            lng: titleLng,
                            lat: titleLat,
                            alt: 1200,
                            text: item.policeStationName
                        },
                        distanceDisplayCondition: {
                            near: 20000, //最近距离
                            far: 200000 //最远距离
                        }
                    })
                const center = this.getCenter(item)
                this.$EventBus.$emit('layerPointAdd', {
                    layerName: 'homePersonLayer',
                    type: 'label',
                    params: {
                        lng: center[0],
                        lat: center[1],
                        alt: 1200,
                        text: '5656'
                    }
                })
                let cylinder = new global.DC.LightCylinderPrimitive(new global.DC.Position(center[0], center[1]), 1200, 1, 600)
                cylinder.setStyle({
                    color: global.DC.Namespace.Cesium.Color.fromBytes(
                        102, 176, 255,
                        255
                    )
                })
                cylinderLayer.addOverlay(cylinder)
                    let cylinder = new global.DC.LightCylinderPrimitive(new global.DC.Position(center[0], center[1]), 1200, 1, 600)
                    cylinder.setStyle({
                        color: global.DC.Namespace.Cesium.Color.fromBytes(
                            102, 176, 255,
                            255
                        )
                    })
                    cylinderLayer.addOverlay(cylinder)
                }
            })
            position2.forEach((item, index) => {
            this.areaCheckoptions.forEach((item, index) => {
                // position2.forEach((item, index) => {
                let str = ''
                item.forEach(it => {
                item.position.forEach(it => {
                    str = str + `${it[0]},${it[1]},${it[2]};`
                })
@@ -563,7 +681,7 @@
                const sortedLatitudeArray = poly.map(item => item.y).sort()
                const centerLongitude = ((parseFloat(sortedLongitudeArray[0]) + parseFloat(sortedLongitudeArray[sortedLongitudeArray.length - 1])) / 2).toFixed(14)
                const centerLatitude = ((parseFloat(sortedLatitudeArray[0]) + parseFloat(sortedLatitudeArray[sortedLatitudeArray.length - 1])) / 2).toFixed(14)
                console.log(centerLongitude, centerLatitude)
                // console.log(centerLongitude, centerLatitude)
                centerLonLat = [Number(centerLongitude), Number(centerLatitude)]
            }
            return centerLonLat