浏览代码

bug修复

zpf 1 年之前
父节点
当前提交
17ba611366
共有 2 个文件被更改,包括 131 次插入62 次删除
  1. 128 59
      src/components/Query/clickQuery/CockpitVector.vue
  2. 3 3
      src/views/cockpit/bjxm.vue

+ 128 - 59
src/components/Query/clickQuery/CockpitVector.vue

@@ -52,16 +52,16 @@ export default {
 
       }
 
-      let bj_sl = {
-        beginTime: store.state.cockpit_date[0],
-        endTime: store.state.cockpit_date[1],
-        jscType: 'jsc_bjxm_csbj_zbmx_cx',
-        id: '4602',
-        val0: word,
+      // let bj_sl = {
+      //   beginTime: store.state.cockpit_date[0],
+      //   endTime: store.state.cockpit_date[1],
+      //   jscType: 'jsc_bjxm_csbj_zbmx_cx',
+      //   id: '4602',
+      //   val0: word,
 
-      }
+      // }
 
-      Promise.all([QueryList(gy_ju), QueryList(bj_sl)]).then((values) => {
+      Promise.all([QueryList(gy_ju)]).then((values) => {
         this.restaurants = [];
         values.forEach((item, index) => {
           item.data.forEach((item, index) => {
@@ -81,7 +81,64 @@ export default {
         console.error(error); // 如果有任何一个 promise 失败,则捕获这个错误  
       });
     },
+    build_data(geojson) {
+      geojson.coordinates.forEach((res) => {
+        console.log('res: ', res);
+        const twoDArray = res[0];
+        const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
+        console.log('oneDArray: ', oneDArray);
+
+        pick_entity.entities.add({
+          polygon: {
+            // 获取指定属性(positions,holes(图形内需要挖空的区域))
+            hierarchy: {
+              positions: Cesium.Cartesian3.fromDegreesArrayHeights(oneDArray),
+            },
+            // 边框
+            outline: true,
+            // 边框颜色
+            outlineColor: Cesium.Color.RED,
+            // 边框尺寸
+            outlineWidth: 2,
+            // 填充的颜色,withAlpha透明度
+            material: Cesium.Color.GREEN.withAlpha(0),
+            // 是否被提供的材质填充
+            fill: true,
+            // 恒定高度
+            height: 1.1,
+            // 显示在距相机的距离处的属性,多少区间内是可以显示的
+            // distanceDisplayCondition: new Cesium.DistanceDisplayCondition(1000, 10000000),
+            // 是否显示
+            show: true,
+            // 顺序,仅当`clampToGround`为true并且支持地形上的折线时才有效。
+            zIndex: 10
+          }
+        });
+
+        // 注意:polygon首尾坐标要一致
+        var polygon = turf.polygon([twoDArray]);
+
+        var centroid = turf.centroid(polygon).geometry.coordinates;
+
+        viewer.camera.flyTo({
+          duration: 1,
+
+          destination: Cesium.Cartesian3.fromDegrees(centroid[0], centroid[1], 3000),
+          // destination: {
+          //     x: -6283267.004204832,
+          //     y: 28123682.896774407,
+          //     z: 23709669.98539126
+          // },
+          orientation: {
+            heading: 6.149339593573709,
+            pitch: -1.539825618847483,
+            roll: 0
+          },
+        });
+
 
+      })
+    },
     querySearchAsync(queryString, cb) {
       var restaurants = this.restaurants;
       var results = queryString ? restaurants.filter(this.createStateFilter(queryString)) : restaurants;
@@ -101,6 +158,9 @@ export default {
     handleSelect(item) {
       let arr = [];
       const that = this;
+      pick_entity = new Cesium.CustomDataSource("pick_entity");
+      viewer.dataSources.add(pick_entity);
+
       Object.keys(item).forEach(key => {
 
         arr.push({
@@ -115,35 +175,62 @@ export default {
           let geojson = wellknown.parse(item[key]);
           console.log('geojson: ', geojson);
 
-          const twoDArray = geojson.coordinates[0];
-          const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
-          console.log('oneDArray: ', oneDArray);
-          pick_entity.entities.add({
-            polygon: {
-              // 获取指定属性(positions,holes(图形内需要挖空的区域))
-              hierarchy: {
-                positions: Cesium.Cartesian3.fromDegreesArrayHeights(oneDArray),
+
+
+          if (geojson.type == 'MultiPolygon') {
+            this.build_data(geojson);
+          } else {
+            const twoDArray = geojson.coordinates[0];
+            const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
+            pick_entity.entities.add({
+              polygon: {
+                // 获取指定属性(positions,holes(图形内需要挖空的区域))
+                hierarchy: {
+                  positions: Cesium.Cartesian3.fromDegreesArrayHeights(oneDArray),
+                },
+                // 边框
+                outline: true,
+                // 边框颜色
+                outlineColor: Cesium.Color.RED,
+                // 边框尺寸
+                outlineWidth: 2,
+                // 填充的颜色,withAlpha透明度
+                material: Cesium.Color.GREEN.withAlpha(0),
+                // 是否被提供的材质填充
+                fill: true,
+                // 恒定高度
+                height: 1.1,
+                // 显示在距相机的距离处的属性,多少区间内是可以显示的
+                // distanceDisplayCondition: new Cesium.DistanceDisplayCondition(1000, 10000000),
+                // 是否显示
+                show: true,
+                // 顺序,仅当`clampToGround`为true并且支持地形上的折线时才有效。
+                zIndex: 10
+              }
+            });
+            // 注意:polygon首尾坐标要一致
+            var polygon = turf.polygon([geojson.coordinates[0]]);
+
+            var centroid = turf.centroid(polygon).geometry.coordinates;
+
+            viewer.camera.flyTo({
+              duration: 1,
+
+              destination: Cesium.Cartesian3.fromDegrees(centroid[0], centroid[1], 3000),
+              // destination: {
+              //     x: -6283267.004204832,
+              //     y: 28123682.896774407,
+              //     z: 23709669.98539126
+              // },
+              orientation: {
+                heading: 6.149339593573709,
+                pitch: -1.539825618847483,
+                roll: 0
               },
-              // 边框
-              outline: true,
-              // 边框颜色
-              outlineColor: Cesium.Color.RED,
-              // 边框尺寸
-              outlineWidth: 2,
-              // 填充的颜色,withAlpha透明度
-              material: Cesium.Color.GREEN.withAlpha(0),
-              // 是否被提供的材质填充
-              fill: true,
-              // 恒定高度
-              height: 1.1,
-              // 显示在距相机的距离处的属性,多少区间内是可以显示的
-              // distanceDisplayCondition: new Cesium.DistanceDisplayCondition(1000, 10000000),
-              // 是否显示
-              show: true,
-              // 顺序,仅当`clampToGround`为true并且支持地形上的折线时才有效。
-              zIndex: 10
-            }
-          });
+            });
+
+
+          }
 
           let flag = true;
           let time = setInterval(() => {
@@ -152,34 +239,16 @@ export default {
           }, 500);
           setTimeout(() => {
             clearInterval(time);
-            pick_entity.entities.values.forEach((res) => {
+            viewer.dataSources.remove(pick_entity);
+            // pick_entity.entities.values.forEach((res) => {
+            //   console.log('res: ', res);
 
-              pick_entity.entities.remove(res);
+            //   pick_entity.entities.remove(res);
 
-            })
+            // })
           }, 6000)
 
 
-          // 注意:polygon首尾坐标要一致
-          var polygon = turf.polygon([geojson.coordinates[0]]);
-
-          var centroid = turf.centroid(polygon).geometry.coordinates;
-
-          viewer.camera.flyTo({
-            duration: 1,
-
-            destination: Cesium.Cartesian3.fromDegrees(centroid[0], centroid[1], 3000),
-            // destination: {
-            //     x: -6283267.004204832,
-            //     y: 28123682.896774407,
-            //     z: 23709669.98539126
-            // },
-            orientation: {
-              heading: 6.149339593573709,
-              pitch: -1.539825618847483,
-              roll: 0
-            },
-          });
 
         }
       });

+ 3 - 3
src/views/cockpit/bjxm.vue

@@ -451,9 +451,9 @@ export default {
 
       this.init_vector();
 
-      this.bjxu_entity = new Cesium.CustomDataSource("bjxu_entity");
-      viewer.dataSources.add(this.bjxu_entity);
-      this.bjxu_entity.show = true
+      // this.bjxu_entity = new Cesium.CustomDataSource("bjxu_entity");
+      // viewer.dataSources.add(this.bjxu_entity);
+      // this.bjxu_entity.show = true
 
     })
   }, //生命周期 - 挂在完成