From 81f54040c2cb65537c6c6e1db8358a39a57dea0d Mon Sep 17 00:00:00 2001
From: mayisheng <admin>
Date: Mon, 15 Aug 2022 16:14:01 +0800
Subject: [PATCH] 1

---
 src/store/modules/popupParams.js |  356 ++++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 256 insertions(+), 100 deletions(-)

diff --git a/src/store/modules/popupParams.js b/src/store/modules/popupParams.js
index 218580c..3789451 100644
--- a/src/store/modules/popupParams.js
+++ b/src/store/modules/popupParams.js
@@ -1,5 +1,11 @@
+import leftNavsData from './pc/leftNavsData'
+window.labelLayer = null
+window.divIcon = null
+window.divIcononces = null
+
 const popupParams = {
     state: {
+        ...leftNavsData.state,
         popupBgUrl: null,
         pupupQRUrl: null,
         terminus: null,
@@ -21,98 +27,103 @@
         addTagPopup: false,
         addTagPosition: null,
 
-        labelLayer: null, //自定义标签图层
+        // labelLayer: null, // 自定义标签图层
         addSignList: true,
         myviewer: null,
         nowlabelLayerData: {},
         labelLayerDataShow: false,
 
-        closeMapClick: false, //关闭地图点击,防止新增标签误触
+        closeMapClick: false // 关闭地图点击,防止新增标签误触
     },
     mutations: {
-        SET_POPUPBGURL(state, popupBgUrl) {
+        ...leftNavsData.mutations,
+        SET_POPUPBGURL (state, popupBgUrl) {
+            // console.log(popupBgUrl, "see33333")
+            if (!popupBgUrl) {
+                return
+            }
             state.popupBgUrl = popupBgUrl
         },
-        SET_POPUPQRURL(state, pupupQRUrl) {
+        SET_POPUPQRURL (state, pupupQRUrl) {
             state.pupupQRUrl = pupupQRUrl
         },
-        SET_TERMINUS(state, terminus) {
+        SET_TERMINUS (state, terminus) {
             state.terminus = terminus
         },
-        SET_STARTINGPOINT(state, startingPoint) {
+        SET_STARTINGPOINT (state, startingPoint) {
             state.startingPoint = startingPoint
         },
-        SET_POINTPOSITION(state, pointPosition) {
+        SET_POINTPOSITION (state, pointPosition) {
             state.pointPosition = pointPosition
         },
-        SET_STATENAME(state, stateName) {
+        SET_STATENAME (state, stateName) {
             state.stateName = stateName
         },
-        SET_SITENAME(state, siteName) {
+        SET_SITENAME (state, siteName) {
             state.siteName = siteName
         },
-        SET_TELEPHONE(state, telephone) {
+        SET_TELEPHONE (state, telephone) {
             state.telephone = telephone
         },
-        SET_INTRODUCETEXT(state, introduceText) {
+        SET_INTRODUCETEXT (state, introduceText) {
             state.introduceText = introduceText
         },
-        SET_PANORAMAURL(state, panoramaUrl) {
+        SET_PANORAMAURL (state, panoramaUrl) {
             state.panoramaUrl = panoramaUrl
         },
-        SET_PANORAMAPOPUP(state, panoramaPopup) {
+        SET_PANORAMAPOPUP (state, panoramaPopup) {
             state.panoramaPopup = panoramaPopup
         },
-        SET_MONITORURL(state, monitorUrl) {
+        SET_MONITORURL (state, monitorUrl) {
             state.monitorUrl = monitorUrl
         },
-        SET_MONITORPOPUP(state, monitorPopup) {
+        SET_MONITORPOPUP (state, monitorPopup) {
             state.monitorPopup = monitorPopup
         },
-        SET_DETAILSPOPUP(state, detailsPopup) {
+        SET_DETAILSPOPUP (state, detailsPopup) {
             state.detailsPopup = detailsPopup
         },
-        SET_POPUPIMGATLAS(state, popupImgAtlas) {
+        SET_POPUPIMGATLAS (state, popupImgAtlas) {
             state.popupImgAtlas = popupImgAtlas
         },
-        SET_TEACHLIST(state, teachList) {
+        SET_TEACHLIST (state, teachList) {
             state.teachList = teachList
         },
-        SET_LIVELIST(state, liveList) {
+        SET_LIVELIST (state, liveList) {
             state.liveList = liveList
         },
 
-        SET_ADDTAGPOPUP(state, addTagPopup) {
+        SET_ADDTAGPOPUP (state, addTagPopup) {
             state.addTagPopup = addTagPopup
         },
 
-        SET_ADDTAGPOSITION(state, addTagPosition) {
+        SET_ADDTAGPOSITION (state, addTagPosition) {
             state.addTagPosition = addTagPosition
         },
-        initLabelLayer(state, val) {
-            if (!state.labelLayer) {
-                state.labelLayer = new global.DC.HtmlLayer("labelLayer");
-                val.addLayer(state.labelLayer);
+        initLabelLayer (state, val) {
+            if (!window.labelLayer) {
+                window.labelLayer = new global.DC.HtmlLayer('labelLayer')
+                val.addLayer(window.labelLayer)
             }
-            state.myviewer = val;
+            state.myviewer = val
         },
 
-        clearLabelLayerIcon(state, val) {
-            if (state.labelLayer) {
-                state.labelLayer.clear();
+        clearLabelLayerIcon (state, val) {
+            if (window.labelLayer) {
+                window.labelLayer.clear()
             }
         },
-        openLabelLayer(state, val) {
+        openLabelLayer (state, val) {
             // console.log(val, "see")
             if (val.show) {
-                state.nowlabelLayerData = val.data;
-                state.labelLayerDataShow = true;
+                state.nowlabelLayerData = val.data
+                state.labelLayerDataShow = true
             } else {
-                state.nowlabelLayerData = {};
-                state.labelLayerDataShow = false;
+                state.nowlabelLayerData = {}
+                state.labelLayerDataShow = false
             }
         },
-        CLEAR_ALL(state, param) {
+        CLEAR_ALL (state, param) {
             state.siteName = param
             state.introduceText = param
             state.telephone = param
@@ -122,12 +133,13 @@
             state.teachList = []
             state.liveList = []
         },
-        set_closeMapClick(state, val) {
-            state.closeMapClick = val;
+        set_closeMapClick (state, val) {
+            state.closeMapClick = val
         }
     },
     actions: {
-        openPopups({
+        ...leftNavsData.actions,
+        openPopups ({
             state,
             commit,
             dispatch
@@ -141,8 +153,8 @@
             //       item: item,
             //     });
             //   });
-            var popup = new global.DC.DivForms(state.viewer, {
-                domId: "divFormsDomBox",
+            var box = new global.DC.DivForms(state.viewer, {
+                domId: 'divFormsDomBox',
                 position: [
                     global.DC.Transform.transformWGS84ToCartesian(
                         new global.DC.Position(
@@ -150,93 +162,95 @@
                             Number(value.lat),
                             Number(value.alt || 0)
                         )
-                    ),
-                ],
-            });
-            dispatch("setOurDataInPoput", value);
-            dispatch("pcFlyView", {
+                    )
+                ]
+            })
+            dispatch('setOurDataInPoput', value)
+            dispatch('pcFlyView', {
                 jd: value.lng,
                 wd: value.lat,
-                viewer: this.viewer,
-            });
+                viewer: this.viewer
+            })
         },
-        setOurDataInPoput({
+        setOurDataInPoput ({
             state,
             commit,
             dispatch
         }, value) {
-            //弹窗使用方法
+            // 弹窗使用方法
 
-            commit("CLEAR_ALL", null);
-
-
-            commit("SET_STATENAME", value.item.mechanismname);
-            commit("SET_PANORAMAURL", value.item.panoramaurl);
-            commit("SET_INTRODUCETEXT", value.item.introduce);
-            var imgArr = value.item.tpurl.split(",");
-            commit("SET_POPUPBGURL", imgArr[0]);
-            commit("SET_POPUPQRURL", value.item.codeurl);
-            commit("SET_POINTPOSITION", [
+            commit('CLEAR_ALL', null)
+            commit('SET_MONITORPOPUP', false)
+            commit('SET_PANORAMAPOPUP', false)
+            commit('SET_STATENAME', value.item.mechanismname)
+            commit('SET_PANORAMAURL', value.item.panoramaurl)
+            commit('SET_INTRODUCETEXT', value.item.introduce)
+            var imgArr = []
+            if (value.item.tpurl) {
+                imgArr = value.item.tpurl.split(',')
+            }
+            commit('SET_POPUPBGURL', imgArr[0])
+            commit('SET_POPUPIMGATLAS', imgArr)
+            commit('SET_POPUPQRURL', value.item.codeurl)
+            commit('SET_POINTPOSITION', [
                 Number(value.lng),
                 Number(value.lat),
                 Number(0),
                 Number(0),
                 Number(-90),
-                Number(0),
-            ]);
-            commit('SET_POPUPIMGATLAS', imgArr)
-            commit("SET_DETAILSPOPUP", true);
+                Number(0)
+            ])
+            commit('SET_DETAILSPOPUP', true)
         },
-        pcMoveView({
+        pcMoveView ({
             state,
             commit,
             dispatch
         }, val) {
-            console.log(val, "see1")
-            val.viewer.camera.setView({
+            global.viewer.camera.setView({
                 // Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
                 // fromDegrees()方法,将经纬度和高程转换为世界坐标
                 destination: global.DC.Namespace.Cesium.Cartesian3.fromDegrees(
                     +val.jd,
                     +val.wd,
-                    400.0
+                    300.0
                 ),
                 orientation: {
                     // 指向
                     heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
                     // 视角
                     pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
-                    roll: 0.0,
-                },
-            });
+                    roll: 0.0
+                }
+            })
         },
-        pcFlyView({
+        pcFlyView ({
             state,
             commit,
             dispatch
         }, val) {
             val.viewer.flyToPosition(
                 new global.DC.Position(Number(val.jd), Number(val.wd), Number(300), Number(0), Number(-90), Number(0)),
-                function () {},
+                function () { },
                 2
             )
         },
-        addLabelLayerIcon({
+        addLabelLayerIcon ({
             state,
             commit,
             dispatch
         }, val) {
-            let list = val.list;
+            const list = val.list
             if (val.clear) {
-                //     state.labelLayer.remove();
-                state.labelLayer.clear();
+                //     window.labelLayer.remove();
+                window.labelLayer.clear()
             }
-            if (val.add) { //刷新列表
-                state.addSignList = !state.addSignList;
-                return;
+            if (val.add) { // 刷新列表
+                state.addSignList = !state.addSignList
+                return
             }
-            for (let i in list) {
-                const divIcon = new global.DC.DivIcon(
+            for (const i in list) {
+                window.divIcononces = new global.DC.DivIcon(
                     new global.DC.Position(
                         Number(list[i].jd),
                         Number(list[i].wd),
@@ -252,17 +266,21 @@
                                   </div>
                               </div>
                           `
-                );
-                //订阅事件
-                divIcon.on(global.DC.MouseEventType.CLICK, (e) => {
+                )
+                // 订阅事件
+                window.divIcononces.on(global.DC.MouseEventType.CLICK, (e) => {
+                    if (state.pinchFlag == true) {
+                        return
+                    }
+
                     // console.log(e);
                     // return;
                     // 定制化窗体
-                    let position = e.position,
-                        lntLat = [e.overlay._position._lng, e.overlay._position._lat];
+                    // const position = e.position
+                    const lntLat = [e.overlay._position._lng, e.overlay._position._lat]
                     // console.log(position, lntLat, list[i], state.myviewer, "see")
-                    new global.DC.DivForms(state.myviewer, {
-                        domId: "labelLayerid",
+                    var box = new global.DC.DivForms(global.viewer, {
+                        domId: 'labelLayerid',
                         position: [
                             global.DC.Transform.transformWGS84ToCartesian(
                                 new global.DC.Position(
@@ -270,34 +288,172 @@
                                     Number(lntLat[1]),
                                     Number(0)
                                 )
-                            ),
-                        ],
-                    });
-                    state.myviewer.camera.setView({
+                            )
+                        ]
+                    })
+                    global.viewer.camera.setView({
                         // Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
                         // fromDegrees()方法,将经纬度和高程转换为世界坐标
                         destination: global.DC.Namespace.Cesium.Cartesian3.fromDegrees(
                             lntLat[0],
                             lntLat[1],
-                            400.0
+                            950.0
                         ),
                         orientation: {
                             // 指向
                             heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
                             // 视角
                             pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
-                            roll: 0.0,
-                        },
-                    });
-                    commit("openLabelLayer", {
+                            roll: 0.0
+                        }
+                    })
+                    commit('openLabelLayer', {
                         show: true,
                         data: list[i]
                     })
-                });
-                state.labelLayer.addOverlay(divIcon);
+                })
+                window.labelLayer.addOverlay(window.divIcononces)
             }
         },
+        addLabelLayerIconMobelUse ({
+            state,
+            commit,
+            dispatch
+        }, val) {
+            const list = val.list
+            if (!window.labelLayer) {
+                window.labelLayer = new global.DC.VectorLayer('labelLayer')
+                global.viewer.addLayer(window.labelLayer)
+                // state.myviewer = val.mviewer
+            }
+            if (val.clear) {
+                //     window.labelLayer.remove();
+                window.labelLayer.clear()
+            }
+            if (val.add) { // 刷新列表
+                state.addSignList = !state.addSignList
+                return
+            }
+            for (const i in list) {
+                const billboard = new global.DC.Billboard(
+                    new global.DC.Position(
+                        Number(list[i].jd),
+                        Number(list[i].wd),
+                        0
+                    ), 'https://map.hit.edu.cn/images/tarrow_xq.png')
+
+                const label = new global.DC.Label(
+                    new global.DC.Position(
+                        Number(list[i].jd),
+                        Number(list[i].wd),
+                        0
+                    ),
+                    list[i].name
+                )
+
+                label.setStyle({
+                    fillColor: global.DC.Color.RED,
+                    style: global.DC.Namespace.Cesium.LabelStyle.FILL_AND_OUTLINE,
+                    outlineColor: global.DC.Color.WHITE, // 边框颜色
+                    outlineWidth: 8, // 边框大小,
+                    font: '12px sans-serif',
+                    pixelOffset: { x: 0, y: -24 }
+                })
+
+                // 订阅事件
+                billboard.on(global.DC.MouseEventType.CLICK, (e) => {
+                    if (state.pinchFlag == true) {
+                        return
+                    }
+                    // console.log(e);
+                    // return;
+                    // 定制化窗体
+                    // const position = e.position
+                    const lntLat = [e.overlay._position._lng, e.overlay._position._lat]
+                    // console.log(position, lntLat, list[i], state.myviewer, "see")
+                    var box = new global.DC.DivForms(global.viewer, {
+                        domId: 'labelLayerid',
+                        position: [
+                            global.DC.Transform.transformWGS84ToCartesian(
+                                new global.DC.Position(
+                                    Number(lntLat[0]),
+                                    Number(lntLat[1]),
+                                    Number(0)
+                                )
+                            )
+                        ]
+                    })
+                    global.viewer.camera.setView({
+                        // Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
+                        // fromDegrees()方法,将经纬度和高程转换为世界坐标
+                        destination: global.DC.Namespace.Cesium.Cartesian3.fromDegrees(
+                            lntLat[0],
+                            lntLat[1],
+                            950.0
+                        ),
+                        orientation: {
+                            // 指向
+                            heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
+                            // 视角
+                            pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
+                            roll: 0.0
+                        }
+                    })
+                    commit('openLabelLayer', {
+                        show: true,
+                        data: list[i]
+                    })
+                })
+
+                label.on(global.DC.MouseEventType.CLICK, (e) => {
+                    if (state.pinchFlag == true) {
+                        return
+                    }
+                    // console.log(e);
+                    // return;
+                    // 定制化窗体
+                    // const position = e.position
+                    const lntLat = [e.overlay._position._lng, e.overlay._position._lat]
+                    // console.log(position, lntLat, list[i], state.myviewer, "see")
+                    var box = new global.DC.DivForms(global.viewer, {
+                        domId: 'labelLayerid',
+                        position: [
+                            global.DC.Transform.transformWGS84ToCartesian(
+                                new global.DC.Position(
+                                    Number(lntLat[0]),
+                                    Number(lntLat[1]),
+                                    Number(0)
+                                )
+                            )
+                        ]
+                    })
+                    global.viewer.camera.setView({
+                        // Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州
+                        // fromDegrees()方法,将经纬度和高程转换为世界坐标
+                        destination: global.DC.Namespace.Cesium.Cartesian3.fromDegrees(
+                            lntLat[0],
+                            lntLat[1],
+                            950.0
+                        ),
+                        orientation: {
+                            // 指向
+                            heading: global.DC.Namespace.Cesium.Math.toRadians(0, 0),
+                            // 视角
+                            pitch: global.DC.Namespace.Cesium.Math.toRadians(-90),
+                            roll: 0.0
+                        }
+                    })
+                    commit('openLabelLayer', {
+                        show: true,
+                        data: list[i]
+                    })
+                })
+
+                window.labelLayer.addOverlay(billboard) // 加入图标
+                window.labelLayer.addOverlay(label)
+            }
+        }
     }
 }
 
-export default popupParams
\ No newline at end of file
+export default popupParams

--
Gitblit v1.9.3