Browse Source

取消点选debugger

zpf 11 months ago
parent
commit
ad419969b5
2 changed files with 91 additions and 76 deletions
  1. 82 3
      src/common/js/cockpit.js
  2. 9 73
      src/views/viewer.vue

+ 82 - 3
src/common/js/cockpit.js

@@ -1,6 +1,8 @@
 
 let manager = {};
 let _viewer = {};
+let manager_entity = {};
+
 // const init_viewer = {
 
 // }
@@ -8,6 +10,10 @@ const init = (viewer) => {
     manager = new Cesium.PrimitiveCollection();
     manager.destroyPrimitives = false;
     viewer.scene.primitives.add(manager);
+
+    manager_entity = new Cesium.CustomDataSource("manager_entity");
+    viewer.dataSources.add(manager_entity);
+
     _viewer = viewer;
 
 }
@@ -26,12 +32,85 @@ const hidden_xzqh = (flag) => {
 }
 
 const hidden_wall = (flag) => {
-    if (_viewer.entities) {
-        _viewer.entities.values.forEach((res) => {
+
+    if (manager_entity.entities) {
+        manager_entity.entities.values.forEach((res) => {
             if (res.name == "立体墙效果" || res.name == "海域") {
                 res.show = flag;
             }
         })
     }
 }
-export { init, addPrimitive, hidden_xzqh, hidden_wall };  
+const pick_xzqh = (pri_name) => {
+    manager_entity.entities.values.forEach((res) => {
+        if (res.properties.name._value == pri_name) {//选中
+            res.billboard.show._value = true;
+        } else {
+            if (res.billboard != undefined) {
+                res.billboard.show._value = false
+
+            }
+        }
+    })
+}
+const add_wall = (obj, positions, res) => {
+    manager_entity.entities.add({
+        name: "立体墙效果",
+        position: Cesium.Cartesian3.fromDegrees(obj.centroid[0], res.properties.centroid[1], 5000),
+        text: obj.name,
+        properties: obj,
+        label: {
+            font: "bolder 18px sans-serif",
+            style: Cesium.LabelStyle.FILL_AND_OUTLINE,
+            text: res.properties.name,//图标名称
+            fillColor: Cesium.Color.fromCssColorString("#ffffff"),
+            pixelOffset: new Cesium.Cartesian2(5, -15),
+            zIndex: 3,
+        },
+        billboard: {
+            // 图像地址,URI或Canvas的属性
+            image: "./static/images/overview/htq-f.png",
+            height: 60,
+            width: 150,
+            scale: 1.0,
+            zIndex: 2,
+            show: false
+        },
+        wall: {
+            positions: positions,
+            // 设置高度
+            maximumHeights: new Array(positions.length).fill(res.properties.extrudedHeight),
+            minimumHeights: new Array(positions.length).fill(0),
+            material: new Cesium.DynamicWallMaterialProperty({
+                color: Cesium.Color.fromBytes(19, 159, 240).withAlpha(0.7),
+                duration: 3000
+            }),
+        }
+    })
+
+}
+const add_hy = (obj, res, oneDArray, xzqh_color) => {
+
+
+    manager_entity.entities.add({
+        position: Cesium.Cartesian3.fromDegrees(res.properties.centroid[0], res.properties.centroid[1], 500),
+        properties: obj,
+        name: "海域",
+        polygon: {
+            zIndex: 1,
+            hierarchy: {
+                positions: Cesium.Cartesian3.fromDegreesArray(oneDArray),
+            },
+            // outline: false,
+            material: Cesium.Color.fromCssColorString(xzqh_color),
+
+            height: 300,
+            extrudedHeight: 350,
+            outline: true,
+            // outlineColor : Cesium.Color.BLACK
+            outlineColor: Cesium.Color.fromCssColorString('#55A1E3'),
+        }
+    })
+
+}
+export { init, addPrimitive, hidden_xzqh, hidden_wall, add_wall, add_hy, pick_xzqh };  

+ 9 - 73
src/views/viewer.vue

@@ -52,7 +52,7 @@ import hyqy from "../../static/data/460200_hyqy.json";
 
 
 import { cockpitInfo } from '@/api/cockpit'
-import { init, addPrimitive, hidden_xzqh, hidden_wall } from "@/common/js/cockpit.js";
+import * as cockpit from "@/common/js/cockpit.js";
 
 export default {
     components: { KJZB, BJXM, TDSC, HYSY, TDSY, GDBH, STXF, WPJG, datePicker, JCBD },
@@ -82,9 +82,9 @@ export default {
             // store.setToolBarShow(true);
 
             // 隐藏行政区划
-            hidden_xzqh(store.state.viewer_flag);
+            cockpit.hidden_xzqh(store.state.viewer_flag);
             // 隐藏墙体
-            hidden_wall(store.state.viewer_flag);
+            cockpit.hidden_wall(store.state.viewer_flag);
         },
         switch() {
             this.flag = !this.flag;
@@ -202,7 +202,6 @@ export default {
                         let obj = JSON.parse(pickObj.id);
 
                         let pri_name = obj.name;
-                        // console.log('pickObj: ', pickObj.primitive.show = false);
                         let adcode = obj.adcode
                         that.params.id = adcode
                         that.params.name = pri_name
@@ -210,20 +209,7 @@ export default {
                         that.setDatas()
                         // 管控指标
                         that.gkzb_xzqh(adcode);
-                        viewer.entities.values.forEach((res) => {
-                            if (res.properties.name._value == pri_name) {//选中
-                                res.billboard.show._value = true;
-                                store.state.regional_information = {
-                                    id: adcode,
-                                    name: pri_name,
-                                }
-                            } else {
-                                if (res.billboard != undefined)
-                                    res.billboard.show._value = false
-
-
-                            }
-                        })
+                        cockpit.pick_xzqh(pri_name);
                     }
 
 
@@ -321,45 +307,14 @@ export default {
                     })
                     // manager.add(addPolygonGeometry)
 
-                    addPrimitive(addPolygonGeometry);
+                    cockpit.addPrimitive(addPolygonGeometry);
 
                     viewer.scene.primitives.add(addPolygonGeometry)
 
                     // 墙体流动效果
                     var positions = Cesium.Cartesian3.fromDegreesArray(oneDArray);
-                    viewer.entities.add({
-                        name: "立体墙效果",
-                        position: Cesium.Cartesian3.fromDegrees(obj.centroid[0], res.properties.centroid[1], 5000),
-                        text: obj.name,
-                        properties: obj,
-                        label: {
-                            font: "bolder 18px sans-serif",
-                            style: Cesium.LabelStyle.FILL_AND_OUTLINE,
-                            text: res.properties.name,//图标名称
-                            fillColor: Cesium.Color.fromCssColorString("#ffffff"),
-                            pixelOffset: new Cesium.Cartesian2(5, -15),
-                            zIndex: 3,
-                        },
-                        billboard: {
-                            // 图像地址,URI或Canvas的属性
-                            image: "./static/images/overview/htq-f.png",
-                            height: 60,
-                            width: 150,
-                            scale: 1.0,
-                            zIndex: 2,
-                            show: false
-                        },
-                        wall: {
-                            positions: positions,
-                            // 设置高度
-                            maximumHeights: new Array(positions.length).fill(res.properties.extrudedHeight),
-                            minimumHeights: new Array(positions.length).fill(0),
-                            material: new Cesium.DynamicWallMaterialProperty({
-                                color: Cesium.Color.fromBytes(19, 159, 240).withAlpha(0.7),
-                                duration: 3000
-                            }),
-                        }
-                    })
+
+                    cockpit.add_wall(obj, positions, res);
                 })
             })
         },
@@ -377,26 +332,7 @@ export default {
                 const twoDArray = res.geometry.coordinates[0];
                 const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
 
-                viewer.entities.add({
-                    position: Cesium.Cartesian3.fromDegrees(res.properties.centroid[0], res.properties.centroid[1], 500),
-                    properties: obj,
-                    name: "海域",
-                    polygon: {
-                        zIndex: 1,
-                        hierarchy: {
-                            positions: Cesium.Cartesian3.fromDegreesArray(oneDArray),
-                        },
-                        // outline: false,
-                        material: Cesium.Color.fromCssColorString(that.xzqh_color),
-
-                        height: 300,
-                        extrudedHeight: 350,
-                        outline: true,
-                        // outlineColor : Cesium.Color.BLACK
-                        outlineColor: Cesium.Color.fromCssColorString('#55A1E3'),
-                    }
-                });
-
+                cockpit.add_hy(obj, res, oneDArray, that.xzqh_color);
             })
         },
         addSceneFun() {
@@ -452,7 +388,7 @@ export default {
 
 
         this.$nextTick((res) => {
-            init(viewer);
+            cockpit.init(viewer);
 
             this.pick_xzqh();
             this.init_xzqh();