Koishi 3 روز پیش
والد
کامیت
ed1e54b1f5
2فایلهای تغییر یافته به همراه54 افزوده شده و 14 حذف شده
  1. 53 13
      src/views/cesium.vue
  2. 1 1
      src/views/weatherComponents/weatherView.vue

+ 53 - 13
src/views/cesium.vue

@@ -294,7 +294,20 @@ export default {
       });
       this.showAllStation(this.viewer, showStation);
     },
+
     coverOnChange(val) {
+      // if (val.name === "风场图" && val.check) {
+      //   this.viewer.scene.screenSpaceCameraController.minimumZoomDistance = 10000000;
+      // } else {
+      //   this.viewer.scene.screenSpaceCameraController.minimumZoomDistance = 100000;
+      // }
+
+      if (val.check) {
+        this.viewer.scene.screenSpaceCameraController.minimumZoomDistance = 10000000;
+      } else {
+        this.viewer.scene.screenSpaceCameraController.minimumZoomDistance = 100000;
+      }
+
       if (val.name === "回放") {
         this.showControl = !this.showControl;
         clearInterval(this.cloudintervalId);
@@ -342,17 +355,25 @@ export default {
         });
       }
     },
+
     test() {
+      // axios
+      //   // .get("http://localhost:3007/api/test", {
+      //   .post("http://localhost:3007/weather/getWeatherWindData", {
+      //     longitude: 106.169866,
+      //     latitude: 38.46637,
+      //     level: "surface",
+      //     variable: "PRATE,PRES,SUNSD,VEG,VIS,VRATE,LCDC",
+      //   })
+      //   .then((res) => {
+      //     console.log(11111, res.data);
+      //   });
       axios
-        // .get("http://localhost:3007/api/test", {
-        .post("http://localhost:3007/weather/getWeatherWindData", {
-          longitude: 106.169866,
-          latitude: 38.46637,
-          level: "surface",
-          variable: "PRATE,PRES,SUNSD,VEG,VIS,VRATE,LCDC",
-        })
+        .get(
+          "https://api.openweathermap.org/data/2.5/weather?lat=34.540833&lon=108.923611&appid={API KEY}"
+        )
         .then((res) => {
-          console.log(11111, res.data);
+          console.log(321321, res.data);
         });
     },
 
@@ -459,6 +480,7 @@ export default {
       );
       // 设置相机离地表的最小距离(单位:米)
       viewer.scene.screenSpaceCameraController.minimumZoomDistance = 100000;
+      // viewer.scene.screenSpaceCameraController.minimumZoomDistance = 10000000;
 
       this.viewer = viewer;
 
@@ -1135,11 +1157,12 @@ export default {
           pitch: Cesium.Math.toRadians(-90),
           roll: 0.0,
         },
-        duration: 3.0,
+        duration: 1.0,
       });
     },
     // 添加风场图
     async showWindLayer() {
+      const that = this;
       if (!this.windLayer) {
         // this.resetViewport(6000000);
         // 色值面板
@@ -1176,11 +1199,28 @@ export default {
           ],
         };
 
-        this.windLayer = await createWind(
-          this.viewer,
-          this.trJsonData(windGridData),
-          CONTROL_COLOR
+        // 获取当前相机位置(经纬度)
+        const cartographic = Cesium.Cartographic.fromCartesian(
+          this.viewer.camera.position
         );
+        const longitude = Cesium.Math.toDegrees(cartographic.longitude);
+        const latitude = Cesium.Math.toDegrees(cartographic.latitude);
+        this.viewer.camera.flyTo({
+          destination: Cesium.Cartesian3.fromDegrees(
+            longitude,
+            latitude,
+            this.viewer.scene.screenSpaceCameraController.minimumZoomDistance
+          ),
+          duration: 1, // 动画时间(秒)
+          complete: async function () {
+            that.windLayer = await createWind(
+              that.viewer,
+              that.trJsonData(windGridData),
+              CONTROL_COLOR
+            );
+          },
+        });
+
         // this.windLayer = new WindLayer(windGridData, {
         //   particleSize: 2.0,
         //   particleOpacity: 0.6,

+ 1 - 1
src/views/weatherComponents/weatherView.vue

@@ -134,7 +134,7 @@
             v-model="windvalue"
             filterable
             clearable
-            placeholder="选择风机"
+            placeholder="选择场站"
             size="small"
             style="width: 100%"
             @change="switchWind"