瀏覽代碼

状管理

zpf 1 年之前
父節點
當前提交
f125484423

+ 0 - 1
src/components/Query/clickQuery/CockpitVector.vue

@@ -43,7 +43,6 @@ export default {
       geojson.coordinates.forEach((res) => {
         const twoDArray = res[0];
         const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
-        console.log('oneDArray: ', oneDArray);
 
         pick_entity.entities.add({
           polygon: {

+ 1 - 0
src/store/store.js

@@ -196,6 +196,7 @@ var store2 = {
         this.state.toolBarActive = newValue;
         this.state.toolBar = [...this.state.toolBar];
     },
+    // 激活某个状态
     setActiveToolBar(newValue) {
         this.state.toolBar[newValue] = true;
 

+ 48 - 0
src/views/cockpit/common/VectorSpace/BoxCommonVector.js

@@ -0,0 +1,48 @@
+let BoxCommonVector_entity = null;
+export const init = (viewer) => {
+
+    if (BoxCommonVector_entity == null) {
+        BoxCommonVector_entity = new Cesium.CustomDataSource("BoxCommonVector_entity");
+        viewer.dataSources.add(BoxCommonVector_entity);
+    }
+
+}
+
+export const add = (oneDArray) => {
+
+    BoxCommonVector_entity.entities.add({
+        polygon: {
+            // 获取指定属性(positions,holes(图形内需要挖空的区域))
+            hierarchy: {
+                positions: Cesium.Cartesian3.fromDegreesArrayHeights(oneDArray),
+            },
+            // 边框
+            outline: true,
+            // 边框颜色
+            outlineColor: Cesium.Color.RED,
+            // 边框尺寸
+            outlineWidth: 10,
+            // 填充的颜色,withAlpha透明度
+            material: Cesium.Color.GREEN.withAlpha(0),
+            // 是否被提供的材质填充
+            fill: true,
+            // 恒定高度
+            height: 1.1,
+            // 显示在距相机的距离处的属性,多少区间内是可以显示的
+            // distanceDisplayCondition: new Cesium.DistanceDisplayCondition(1000, 10000000),
+            // 是否显示
+            show: true,
+            // 顺序,仅当`clampToGround`为true并且支持地形上的折线时才有效。
+            zIndex: 10
+        }
+    });
+}
+export const remove = () => {
+    viewer.dataSources.remove(BoxCommonVector_entity);
+}
+
+export const switch_show = (flag) => {
+    BoxCommonVector_entity.entities.values.forEach((res) => {
+        res.show = flag;
+    })
+}

+ 19 - 15
src/views/cockpit/common/VectorSpace/BoxCommonVector.vue

@@ -24,9 +24,9 @@
 
                 </el-table-column>
 
-                <el-table-column fixed="right" label="操作" width="90">
+                <el-table-column fixed="right" label="操作" width="50">
                     <template slot-scope="scope">
-                        <el-button @click="info(scope.row)" type="text" size="small">详情</el-button>
+                        <!-- <el-button @click="info(scope.row)" type="text" size="small">详情</el-button> -->
                         <el-button @click="go(scope.row)" type="text" size="small">定位</el-button>
                     </template>
                 </el-table-column>
@@ -42,7 +42,7 @@ import * as tdsy from "@/views/cockpit/js/tdsy";
 import * as wellknown from "wellknown";
 import * as turf from "@turf/turf";
 
-let pick_entity = null;
+let BoxCommonVector_entity = null;
 export default {
     data() {
         return {
@@ -83,7 +83,7 @@ export default {
         },
         info() { },
         switch_show(flag) {
-            pick_entity.entities.values.forEach((res) => {
+            BoxCommonVector_entity.entities.values.forEach((res) => {
                 res.show = flag;
             })
         },
@@ -93,7 +93,7 @@ export default {
                 const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
                 console.log('oneDArray: ', oneDArray);
 
-                pick_entity.entities.add({
+                BoxCommonVector_entity.entities.add({
                     polygon: {
                         // 获取指定属性(positions,holes(图形内需要挖空的区域))
                         hierarchy: {
@@ -147,8 +147,8 @@ export default {
         go(item) {
             let arr = [];
             const that = this;
-            pick_entity = new Cesium.CustomDataSource("pick_entity");
-            viewer.dataSources.add(pick_entity);
+            BoxCommonVector_entity = new Cesium.CustomDataSource("BoxCommonVector_entity");
+            viewer.dataSources.add(BoxCommonVector_entity);
 
             Object.keys(item).forEach(key => {
 
@@ -168,7 +168,7 @@ export default {
                     } else {
                         const twoDArray = geojson.coordinates[0];
                         const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
-                        pick_entity.entities.add({
+                        BoxCommonVector_entity.entities.add({
                             polygon: {
                                 // 获取指定属性(positions,holes(图形内需要挖空的区域))
                                 hierarchy: {
@@ -224,13 +224,17 @@ export default {
                         that.switch_show(flag);
                     }, 500);
                     setTimeout(() => {
-                        clearInterval(time);
-                        console.log("s");
-                        console.log(pick_entity);
-                        viewer.dataSources.remove(pick_entity);
+                        // clearInterval(time);
+                        console.log(BoxCommonVector_entity);
+                        try {
+                            viewer.dataSources.remove(BoxCommonVector_entity);
+                        } catch (error) {
+                            console.log('error: ', error);
+
+                        }
 
 
-                    }, 6000)
+                    }, 1000)
 
 
 
@@ -296,8 +300,8 @@ export default {
         const that = this;
         this.$nextTick(() => {
 
-            pick_entity = new Cesium.CustomDataSource("pick_entity");
-            viewer.dataSources.add(pick_entity);
+            // BoxCommonVector_entity = new Cesium.CustomDataSource("BoxCommonVector_entity");
+            // viewer.dataSources.add(BoxCommonVector_entity);
 
         });
     }