1
mayisheng
2022-08-15 81f54040c2cb65537c6c6e1db8358a39a57dea0d
src/pcviews/tool/sign.vue
@@ -5,12 +5,12 @@
                <img class="icon deblurring" src="/img/icon/tool-sign.png" alt />
                <span>地图标记</span>
            </div>
            <img class="btn-box" @click.stop="addSign" src="/img/navicon/add.png" alt />
            <img class="close" src="/img/navicon/close.png" alt @click="closeModel" />
            <img class="btn-box deblurring" @click.stop="addSign" src="/img/navicon/add.png" alt />
            <img class="close deblurring" src="/img/navicon/close.png" alt @click="closeModel" />
        </template>
        <template slot="public-box-content">
            <div class="list-box">
                <ul v-show="signList.length > 0">
            <div class="list-box" v-loading="loading">
                <ul v-show="signShow">
                    <li v-for="(item, index) in signList" :key="index" @click="dingw(item)">
                        <img src="/img/icon/sign-list.png" alt />
                        {{ item.name }}
@@ -23,7 +23,7 @@
                        ></el-button>
                    </li>
                </ul>
                <div v-show="signList.length == 0" class="no-data">
                <div v-show="!signShow" class="no-data">
                    <img src="/img/icon/no-data.png" alt />
                    <div>暂无数据</div>
                </div>
@@ -39,15 +39,17 @@
export default {
    data () {
        return {
            loading: true,
            signList: [],
            signShow: true,
            destroyedFlag: true
        }
    },
    computed: {
        ...mapGetters(['viewer', 'addSignList'])
        ...mapGetters(['addSignList'])
    },
    mounted () {
        this.$store.commit('initLabelLayer', this.viewer)
        this.$store.commit('initLabelLayer', global.viewer)
        this.getData()
    },
    watch: {
@@ -57,7 +59,6 @@
    },
    methods: {
        dingw (item) {
            const that = this
            // console.log(item);
            // this.$store.dispatch("mapFlyTo", {
            //   lntLat: [item.jd, item.wd, 120], //114.04020791, 27.62934732
@@ -67,13 +68,13 @@
            //   noOpen: true,
            //   mviewer: that.viewer,
            // });
            that.viewer.camera.setView({
            global.viewer.camera.setView({
                // Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
                // fromDegrees()方法,将经纬度和高程转换为世界坐标
                destination: global.DC.Namespace.Cesium.Cartesian3.fromDegrees(
                    item.jd,
                    item.wd,
                    400.0
                    950.0
                ),
                orientation: {
                    // 指向
@@ -104,10 +105,20 @@
        },
        getData () {
            const that = this
            that.loading = true
            const oks = setTimeout(() => {
                that.loading = false
                that.signShow = false
            }, 5000)
            getlabel().then((res) => {
                clearTimeout(oks)
                console.log(res)
                const data = res.data.data.records
                that.signList = data
                that.signList.length > 0
                    ? (that.signShow = true)
                    : (that.signShow = false)
                that.loading = false
                // that.$store.commit("clearLabelLayerIcon");
                that.$store.dispatch('addLabelLayerIcon', {
                    list: data,
@@ -116,31 +127,29 @@
            })
        },
        moveMessage (e, b) {
            if (b == '') {
                this.viewer.tooltip.enable = false
            } else {
                this.viewer.tooltip.enable = true
                this.viewer.tooltip.showAt(e.windowPosition, b)
            }
            global.viewer.tooltip.enable = true
            global.viewer.tooltip.showAt(e.windowPosition, b)
        },
        mouserMove (e) {
            this.moveMessage(e, '点击确认标注位置')
        },
        addSign () {
            var that = this
            this.$store.commit('set_closeMapClick', true)
            // console.log("开始", "see");
            that.viewer.on(global.DC.MouseEventType.MOUSE_MOVE, (e) =>
                that.moveMessage(e, '点击确认标注位置')
            )
            global.viewer.on(global.DC.MouseEventType.MOUSE_MOVE, that.mouserMove)
            that.viewer.once(global.DC.MouseEventType.CLICK, (e) => {
            global.viewer.once(global.DC.MouseEventType.CLICK, (e) => {
                if (that.destroyedFlag == false) return
                that.viewer.on(global.DC.MouseEventType.MOUSE_MOVE, (e) =>
                    that.moveMessage(e, '')
                )
                global.viewer.tooltip.showAt({ x: 100, y: 100 }, '')
                global.viewer.tooltip.enable = false
                global.viewer.off(global.DC.MouseEventType.MOUSE_MOVE, that.mouserMove)
                // eslint-disable-next-line no-unused-vars
                const popup = new global.DC.DivForms(this.viewer, {
                var div = new global.DC.DivForms(global.viewer, {
                    domId: 'AddTagBox',
                    position: [
                        global.DC.Transform.transformWGS84ToCartesian(
@@ -162,16 +171,18 @@
            this.$store.dispatch('delVisitedViews', this.$route)
            this.$router.push('/pcLayout/default')
            this.$store.commit('clearLabelLayerIcon')
            this.destroyedFlag = false
            global.viewer.tooltip.showAt({ x: 100, y: 100 }, '')
            global.viewer.tooltip.enable = false
            global.viewer.off(global.DC.MouseEventType.MOUSE_MOVE, this.mouseMove)
        }
    },
    destroyed () {
        var that = this
        that.destroyedFlag = false
        if (global.DC) {
            that.viewer.on(global.DC.MouseEventType.MOUSE_MOVE, (e) =>
                that.moveMessage(e, '')
            )
        }
        global.viewer.tooltip.showAt({ x: 100, y: 100 }, '')
        global.viewer.tooltip.enable = false
        global.viewer.off(global.DC.MouseEventType.MOUSE_MOVE, that.mouseMove)
        this.$store.commit('clearLabelLayerIcon')
    }
}