+
liuyg
2022-01-17 a3fadb577e4d18c1d7ff60e23be4f3d27f63b9a3
src/components/leftNav/index.vue
@@ -14,6 +14,8 @@
<script>
import { getLifeList, getMonitorList, getSceneList, getWayList, getTagList } from '@/api/pc/leftNav/index'
export default {
    name: 'leftNav',
    computed: {},
@@ -46,12 +48,20 @@
                },
                {
                    flag: false,
                    label: '活动',
                    img: '/img/leftnav/activity.png',
                    normal: '/img/leftnav/activity.png',
                    checked: '/img/leftnav/activity-checked.png',
                    layer: 'activityLayer'
                    label: '监控',
                    img: '/img/leftnav/monitor.png',
                    normal: '/img/leftnav/monitor.png',
                    checked: '/img/leftnav/monitor-checked.png',
                    layer: 'monitorLayer'
                },
                // {
                //     flag: false,
                //     label: '活动',
                //     img: '/img/leftnav/activity.png',
                //     normal: '/img/leftnav/activity.png',
                //     checked: '/img/leftnav/activity-checked.png',
                //     layer: 'activityLayer'
                // },
                {
                    flag: false,
                    label: 'AED',
@@ -82,6 +92,7 @@
            tagLayer: null,
            wayLayer: null,
            sceneLayer: null,
            monitorLayer: null,
            activityLayer: null,
            aedLayer: null,
            parkLayer: null,
@@ -98,8 +109,8 @@
        generatePosition (num) {
            const list = []
            for (let i = 0; i < num; i++) {
                const lng = 121.44405783 + Math.random() * 0.5
                const lat = 31.19480456 + Math.random() * 0.5
                const lng = 115.86271917 + Math.random() * 0.01
                const lat = 28.73615593 + Math.random() * 0.02
                list.push(new this.DC.Position(lng, lat, 0))
            }
            return list
@@ -115,93 +126,166 @@
            }
        },
        initialize (viewer) {
            var that = this
            viewer.scene.globe.depthTestAgainstTerrain = false
            this.viewer = viewer
            this.tagLayer = new this.DC.HtmlLayer('tagLayer')
            viewer.addLayer(this.tagLayer)
            this.wayLayer = new this.DC.HtmlLayer('wayLayer')
            viewer.addLayer(this.wayLayer)
            this.sceneLayer = new this.DC.VectorLayer('sceneLayer')
            this.sceneLayer = new this.DC.HtmlLayer('sceneLayer')
            viewer.addLayer(this.sceneLayer)
            this.monitorLayer = new this.DC.HtmlLayer('monitorLayer')
            viewer.addLayer(this.monitorLayer)
            this.aedLayer = new this.DC.VectorLayer('aedLayer')
            viewer.addLayer(this.aedLayer)
            this.parkLayer = new this.DC.HtmlLayer('parkLayer')
            viewer.addLayer(this.parkLayer)
            this.comeLayer = new this.DC.VectorLayer('comeLayer')
            viewer.addLayer(this.comeLayer)
            const positions1 = this.generatePosition(50)
            positions1.forEach((item, index) => {
                const divIcon = new this.DC.DivIcon(
                    item,
                    `
            getTagList().then(res => {
                res.data.data.forEach(item => {
                    const divIcon = new this.DC.DivIcon(
                        new that.DC.Position(Number(item.jd), Number(item.wd), 0),
                        `
                        <div class="tag-entitys-box">
                            <div class="tag-content">
                                南门口
                                ${item.mechanismname}
                            </div>
                            <div class="tag-angle-content">
                                <img src="https://map.hit.edu.cn/images/tarrow_xq.png">
                            </div>
                        </div>
                    `
                )
                this.tagLayer.addOverlay(divIcon)
                    )
                    this.tagLayer.addOverlay(divIcon)
                })
                this.tagLayer.show = false
            })
            const positions2 = this.generatePosition(50)
            positions2.forEach((item, index) => {
                const divIcon = new this.DC.DivIcon(
                    item,
                    `
            getWayList().then(res => {
                res.data.data.forEach(item => {
                    const divIcon = new this.DC.DivIcon(
                        new that.DC.Position(Number(item.jd), Number(item.wd), 0),
                        `
                        <div  class="way-entitys-box">
                            <div  class="way-title" style="border: white 1px solid; padding-left: 2px;font-size: 12px; background: #0066ff;  width: 12px;line-height: 13px; padding:2px 1px 2px 1px; color:white;">
                                工建街
                                 ${item.roadname}
                            </div>
                            <div  class="way-sign-box">
                                <img src="https://map.hit.edu.cn/images/roadsign3.png">
                            </div>
                        </div>
                    `
                )
                this.wayLayer.addOverlay(divIcon)
            })
            const positions3 = this.generatePosition(50)
            positions3.forEach(item => {
                const billboard = new this.DC.Billboard(item, '/img/leftnav/map-panorama.png')
                billboard.size = [16, 16]
                this.sceneLayer.addOverlay(billboard)
            })
            const positions4 = this.generatePosition(10)
            positions4.forEach((item, index) => {
                const label = new this.DC.Label(item, '建筑AED')
                label.setStyle({
                    fillColor: this.DC.Color.ORANGERED,
                    font: '10px sans-serif',
                    pixelOffset: { x: 0, y: -16 }
                    )
                    this.wayLayer.addOverlay(divIcon)
                })
                this.aedLayer.addOverlay(label)
                const billboard = new this.DC.Billboard(item, '/img/leftnav/map-aed.png')
                billboard.size = [16, 16]
                this.aedLayer.addOverlay(billboard)
                this.wayLayer.show = false
            })
            const positions5 = this.generatePosition(120)
            positions5.forEach((item, index) => {
                const divIcon = new this.DC.DivIcon(
                    item,
                    `
            getMonitorList().then(res => {
                res.data.data.forEach(item => {
                    console.log(item, 456)
                    const divIcon = new this.DC.DivIcon(
                        new that.DC.Position(Number(item.jd), Number(item.wd), 0),
                        `
                        <img class="monitor-entitys-box" src="/img/leftnav/map-monitor.png" alt="">
                        `
                    )
                    divIcon.attrParams = item
                    this.monitorLayer.addOverlay(divIcon)
                    divIcon.on(that.DC.MouseEventType.CLICK, e => {
                        this.$store.commit('SET_PANORAMAPOPUP', false)
                        this.$store.commit('SET_DETAILSPOPUP', false)
                        this.$store.commit('SET_STATENAME', e.overlay.attrParams.mechanismname)
                        this.$store.commit('SET_MONITORURL', e.overlay.attrParams.videourl)
                        // eslint-disable-next-line new-cap
                        var positions = this.DC.Transform.transformWGS84ToCartesian(new this.DC.Position.fromArray([Number(item.jd), Number(item.wd), 0, 0, -90, 0]))
                        this.viewer.scene.globe.depthTestAgainstTerrain = false
                        // eslint-disable-next-line no-unused-vars
                        var monitor = new this.DC.PanoramaBox(this.viewer, {
                            domId: 'MonitorBox',
                            position: [
                                positions
                            ]
                        })
                        this.$store.commit('SET_MONITORPOPUP', true)
                    })
                })
                this.monitorLayer.show = false
            })
            getSceneList().then(res => {
                res.data.data.forEach(item => {
                    console.log(item, 123)
                    const divIcon = new this.DC.DivIcon(
                        new that.DC.Position(Number(item.jd), Number(item.wd), 0),
                        `
                        <img class="scene-entitys-box" src="/img/leftnav/map-panorama.png" alt="">
                        `
                    )
                    divIcon.attrParams = item
                    this.sceneLayer.addOverlay(divIcon)
                    divIcon.on(that.DC.MouseEventType.CLICK, e => {
                        this.$store.commit('SET_DETAILSPOPUP', false)
                        this.$store.commit('SET_MONITORPOPUP', false)
                        this.$store.commit('SET_STATENAME', e.overlay.attrParams.mechanismname)
                        this.$store.commit('SET_PANORAMAURL', e.overlay.attrParams.panoramaurl)
                        // eslint-disable-next-line new-cap
                        var positions = this.DC.Transform.transformWGS84ToCartesian(new this.DC.Position.fromArray([Number(item.jd), Number(item.wd), 0, 0, -90, 0]))
                        this.viewer.scene.globe.depthTestAgainstTerrain = false
                        // eslint-disable-next-line no-unused-vars
                        var panorama = new this.DC.PanoramaBox(this.viewer, {
                            domId: 'PanoramaBox',
                            position: [
                                positions
                            ]
                        })
                        this.$store.commit('SET_PANORAMAPOPUP', true)
                    })
                })
                this.sceneLayer.show = false
            })
            getLifeList({ lifetype: 9 }).then(res => {
                res.data.data.forEach(item => {
                    const label = new this.DC.Label(new that.DC.Position(Number(item.jd), Number(item.wd), 0), item.mechanismname)
                    label.setStyle({
                        fillColor: this.DC.Color.CRIMSON,
                        style: that.DC.Namespace.Cesium.LabelStyle.FILL_AND_OUTLINE,
                        outlineColor: that.DC.Color.WHITE, // 边框颜色
                        outlineWidth: 8, // 边框大小,
                        font: '14px sans-serif',
                        pixelOffset: { x: 0, y: -24 }
                    })
                    this.aedLayer.addOverlay(label)
                    const billboard = new this.DC.Billboard(new that.DC.Position(Number(item.jd), Number(item.wd), 0), '/img/leftnav/map-aed.png')
                    billboard.size = [20, 20]
                    this.aedLayer.addOverlay(billboard)
                })
                this.aedLayer.show = false
            })
            getLifeList({ lifetype: 11 }).then(res => {
                res.data.data.forEach(item => {
                    const divIcon = new this.DC.DivIcon(
                        new that.DC.Position(Number(item.jd), Number(item.wd), 0),
                        `
                        <div class="park-entitys-box">
                            <div class="park-title" alt="校外街路侧停车场">
                            <div class="park-title" alt="${item.mechanismname}">
                            </div>
                            <div class="park-sign-box">
                                <div>
                                    <img src="https://map.hit.edu.cn/images/p-biao.png" width="14" height="14" alt="校外街路侧停车场" title="校外街路侧停车场">
                                    <img src="https://map.hit.edu.cn/images/p-biao.png" width="14" height="14" alt="${item.mechanismname}" title="${item.mechanismname}">
                                </div>
                                <div>
                                    <img src="https://map.hit.edu.cn/images/roadsign.png" width="5" height="21">
@@ -209,34 +293,32 @@
                            </div>
                        </div>
                    `
                )
                this.parkLayer.addOverlay(divIcon)
            })
            const positions6 = this.generatePosition(10)
            positions6.forEach((item, index) => {
                const label = new this.DC.Label(item, '数字视觉')
                label.setStyle({
                    fillColor: this.DC.Color.PURPLE,
                    outlineColor: this.DC.Color.WHITE, // 边框颜色
                    outlineWidth: 2, // 边框大小,
                    font: '10px sans-serif',
                    pixelOffset: { x: 0, y: -16 }
                    )
                    this.parkLayer.addOverlay(divIcon)
                })
                this.comeLayer.addOverlay(label)
                const billboard = new this.DC.Billboard(item, '/img/leftnav/map-activity.png')
                billboard.size = [16, 16]
                this.comeLayer.addOverlay(billboard)
                this.parkLayer.show = false
            })
            this.tagLayer.show = false
            this.wayLayer.show = false
            this.sceneLayer.show = false
            this.aedLayer.show = false
            this.parkLayer.show = false
            this.comeLayer.show = false
            getLifeList({ lifetype: 12 }).then(res => {
                res.data.data.forEach(item => {
                    const label = new that.DC.Label(new that.DC.Position(Number(item.jd), Number(item.wd), 0), item.mechanismname)
                    label.setStyle({
                        fillColor: that.DC.Color.FUCHSIA,
                        style: that.DC.Namespace.Cesium.LabelStyle.FILL_AND_OUTLINE,
                        outlineColor: that.DC.Color.WHITE, // 边框颜色
                        outlineWidth: 8, // 边框大小,
                        font: '14px sans-serif',
                        pixelOffset: { x: 0, y: -24 }
                    })
                    that.comeLayer.addOverlay(label)
                    const billboard = new that.DC.Billboard(new that.DC.Position(Number(item.jd), Number(item.wd), 0), '/img/leftnav/map-activity.png')
                    billboard.size = [20, 20]
                    that.comeLayer.addOverlay(billboard)
                })
                this.comeLayer.show = false
            })
        }
    }
}
@@ -245,39 +327,45 @@
<style scoped lang='scss'>
.left-nav {
    position: fixed;
    top: 15%;
    right: 6%;
    top: 160px;
    right: 30px;
    // bottom: 20px;
    // left: 0;
    z-index: 1;
    li {
        margin-bottom: 8px;
        font-weight: 400;
        display: block;
        width: 98px;
        height: 33px;
        line-height: 33px;
        background-color: #fff;
        border-radius: 17px;
        text-align: center;
        font-size: 0;
        cursor: pointer;
    ul {
        // display: flex;
        li {
            // margin: 0 8px;
            margin-bottom: 12px;
            font-weight: 400;
            display: block;
            width: 98px;
            height: 33px;
            line-height: 33px;
            background-color: #fff;
            border-radius: 17px;
            text-align: center;
            font-size: 0;
            cursor: pointer;
        img {
            width: 24px;
            height: 24px;
            vertical-align: middle;
            margin-right: 10px;
            image-rendering: -moz-crisp-edges;
            image-rendering: -o-crisp-edges;
            image-rendering: -webkit-optimize-contrast;
            image-rendering: crisp-edges;
            -ms-interpolation-mode: nearest-neighbor;
        }
            img {
                width: 24px;
                height: 24px;
                vertical-align: middle;
                margin-right: 10px;
                image-rendering: -moz-crisp-edges;
                image-rendering: -o-crisp-edges;
                image-rendering: -webkit-optimize-contrast;
                image-rendering: crisp-edges;
                -ms-interpolation-mode: nearest-neighbor;
            }
        span {
            display: inline-block;
            vertical-align: middle;
            font-size: 14px;
            color: #2f2f2f;
            span {
                display: inline-block;
                vertical-align: middle;
                font-size: 14px;
                color: #2f2f2f;
            }
        }
    }
}