瀏覽代碼

基础修改

sunzehao 1 月之前
父節點
當前提交
ba6c08655e
共有 3 個文件被更改,包括 73 次插入36 次删除
  1. 18 12
      src/views/cesium.vue
  2. 51 20
      src/views/cesiumComponents/topographicMap.vue
  3. 4 4
      src/views/weatherComponents/weatherView.vue

+ 18 - 12
src/views/cesium.vue

@@ -249,7 +249,7 @@ export default {
     if (this.showDevInfoBox) {
       this.initSystemInfo();
     }
-    this.test();
+    this.cityModel();
     this.getData(106.169866, 38.46637);
   },
 
@@ -266,7 +266,7 @@ export default {
   },
 
   methods: {
-    async test() {
+    async cityModel() {
       // 添加OSM建筑 3D 模型
       try {
         Cesium.createOsmBuildingsAsync().then((buildings) => {
@@ -819,9 +819,9 @@ export default {
       const that = this;
       this.viewer.camera.flyTo({
         destination: Cesium.Cartesian3.fromDegrees(
-          106.169866,
-          38.46637,
-          height || 10000
+        //   106.169866,
+        //   38.46637,
+        //   height || 10000
 
           // 106.2,
           // 38.467,
@@ -831,16 +831,22 @@ export default {
           // 23.109,
           // 1000
 
-          // 121.47,
-          // 31.23,
-          // 1000
+          121.47,
+          31.23,
+          1000
         ),
         orientation: {
-          heading: Cesium.Math.toRadians(0),
-          pitch: Cesium.Math.toRadians(-90),
-          roll: 0.0,
+          heading: 1,
+          pitch: -0.2,
+          roll: 0,
         },
-        duration: 1.0,
+        duration: 3,
+        // orientation: {
+        //   heading: Cesium.Math.toRadians(0),
+        //   pitch: Cesium.Math.toRadians(-90),
+        //   roll: 0.0,
+        // },
+        // duration: 1.0,
         complete() {
           // 为什么要加这个?因为破库地球没完全加载完成时如果执行了监听鼠标滑动事件会光速报错滑跪
           if (!that.loadDone) {

+ 51 - 20
src/views/cesiumComponents/topographicMap.vue

@@ -109,31 +109,44 @@ export default {
       //     "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIwYTQwNDk3MC05YTZkLTQ2ZTEtODc0MS1lZTFkYjFlOTFmNmQiLCJpZCI6MTcyNDQ1LCJpYXQiOjE3NTQ4ODA4MzF9.KnhENYiHxNwTkhTWRA-lHqG59coLVT2FsIyOru2TV3E";
       const box = document.getElementById("cesiumContainer");
       const viewer = new Cesium.Viewer(box, {
-        animation: false, //是否创建动画小器件,左下角仪表
-        baseLayerPicker: false, //是否显示图层选择器,右上角图层选择按钮
-        baseLayer: false, // 不显示默认图层
-        fullscreenButton: false, //是否显示全屏按钮,右下角全屏选择按钮
-        timeline: false, //是否显示时间轴
-        infoBox: false, //是否显示信息框
-        sceneModePicker: false, //是否显示场景模式切换按钮
+        // animation: false, //是否创建动画小器件,左下角仪表
+        // baseLayerPicker: false, //是否显示图层选择器,右上角图层选择按钮
+        // baseLayer: false, // 不显示默认图层
+        // fullscreenButton: false, //是否显示全屏按钮,右下角全屏选择按钮
+        // timeline: false, //是否显示时间轴
+        // infoBox: false, //是否显示信息框
+        // sceneModePicker: false, //是否显示场景模式切换按钮
+        // vrButton: false,
+        // geocoder: false, //是否显示地理编码按钮
+        // homeButton: false, //是否显示地图导航按钮
+        // selectionIndicator: false,
+        // navigationHelpButton: false,
+        // shouldAnimate: true,
+        // imageryProvider: false, //控制默认底图的显示
+        // showGroundAtmosphere: false,
+        // depthTestAgainstTerrain: true,
+        // dynamicAtmosphereLightingFromSun: false,
+        geocoder: false, // 地址搜索控件
+        homeButton: false, // 返回地图初始位置控件
+        infoBox: false, // 地图默认的信息控件
+        sceneModePicker: false, // 场景模式切换控件
+        baseLayerPicker: false, // 底图切换控件
+        navigationHelpButton: false, // 帮助控件
+        animation: false, // 动画控制控件
+        timeline: false, // 时间线控件
+        fullscreenButton: false, // 全屏按钮控件
+        // imageryProvider: true, // 是否显示 Cesium 默认地图的底图
         vrButton: false,
-        geocoder: false, //是否显示地理编码按钮
-        homeButton: false, //是否显示地图导航按钮
         selectionIndicator: false,
-        navigationHelpButton: false,
         shouldAnimate: true,
-        imageryProvider: false, //控制默认底图的显示
-        showGroundAtmosphere: false,
-        depthTestAgainstTerrain: true,
-        dynamicAtmosphereLightingFromSun: false,
       });
 
-      const url =
-        "https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer";
-      const layer = Cesium.ImageryLayer.fromProviderAsync(
-        Cesium.ArcGisMapServerImageryProvider.fromUrl(url)
-      );
-      viewer.imageryLayers.add(layer);
+    //   const url =
+    //     "https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer";
+    //   const layer = Cesium.ImageryLayer.fromProviderAsync(
+    //     Cesium.ArcGisMapServerImageryProvider.fromUrl(url)
+    //   );
+    //   viewer.imageryLayers.add(layer);
 
       viewer._cesiumWidget._creditContainer.style.display = "none";
       viewer.scene.globe.enableLighting = false;
@@ -195,6 +208,8 @@ export default {
       viewer.scene.light = directionalLight;
 
       this.viewer = viewer;
+        this.cityModel();
+
     },
 
     // 生成随机数
@@ -209,6 +224,22 @@ export default {
       }
     },
 
+    async cityModel() {
+      // 添加OSM建筑 3D 模型
+      try {
+        Cesium.createOsmBuildingsAsync().then((buildings) => {
+          this.viewer.scene.primitives.add(buildings);
+        });
+
+        this.viewer.terrainProvider = await Cesium.createWorldTerrainAsync({
+          requestVertexNormals: true,
+          requestWaterMask: true,
+        });
+      } catch (e) {
+        console.log("error", e);
+      }
+    },
+
     getWtStatue(code) {
       if (code === 1) {
         return "#fff";

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

@@ -30,7 +30,7 @@
             </div>
 
             <div class="info-section">
-                <h3>天气信息--宁夏</h3>
+                <h3>天气信息--上海</h3>
                 <div class="info-item">
                     <span class="label">平均风向</span><span class="value">12.9°</span>
                 </div>
@@ -52,13 +52,13 @@
             </div>
 
             <div class="info-section">
-                <h3>操作信息</h3>
+                <h3>预警信息</h3>
                 <div class="info-item">
-                    <span class="label">可用性</span><span class="value">100%</span>
+                    <span class="label">降雨概率</span><span class="value">100%</span>
                 </div>
                 <div class="op-progress-bar"><div class="op-progress-bar-inner" style="width: 100%;"></div></div>
                 <div class="info-item" style="margin-top: 15px;">
-                    <span class="label">容量因子</span><span class="value">32.6%</span>
+                    <span class="label">云层密度</span><span class="value">32.6%</span>
                 </div>
                 <div class="op-progress-bar"><div class="op-progress-bar-inner" style="width: 32.6%;"></div></div>
             </div>