Browse Source

更新香港地图建筑

Alfyn 2 tuần trước cách đây
mục cha
commit
ad21986b32
2 tập tin đã thay đổi với 56 bổ sung26 xóa
  1. 26 9
      src/views/modelView/IndexPage.vue
  2. 30 17
      src/views/modelView/MoldClosingPage.vue

+ 26 - 9
src/views/modelView/IndexPage.vue

@@ -81,14 +81,7 @@ export default {
       window.api = new window.API(this.$store.state.model.defaults) //api对象后面调用接口要全程使用,控制好作用域
       window.api.Public.setTopRenderState(true)
       window.api.Public.setSceneRenderState(false) //实时渲染
-      //设置gis地图
-      window.api.Public.AddImageryProvider(
-      "https://mapapi.geodata.gov.hk/gs/api/v1.0.0/xyz/imagery/WGS84/{z}/{x}/{y}.png",
-      true,
-      {
-        serverType: 0,
-        maximumLevel: 19,
-      });
+      this.loadHKMap()
       this.startTime = new Date()
       this.addModel([...this.modelList])
     },
@@ -181,7 +174,31 @@ export default {
           lightweightName : lightweightName
         }
       });
-    }
+    },
+    loadHKMap() {
+      //设置gis地图
+      window.api.Public.AddImageryProvider(
+        'https://mapapi.geodata.gov.hk/gs/api/v1.0.0/xyz/imagery/WGS84/{z}/{x}/{y}.png',
+        true,
+        {
+          serverType: 0,
+          maximumLevel: 19,
+        }
+      )
+      //加载建筑模型
+      window.api.Model.mergeModel(
+        'https://data1.map.gov.hk/api/3d-data/3dtiles/f2/tileset.json?key=3967f8f365694e0798af3e7678509421',
+        'hkBuilding',
+        (res) => {
+          console.log('模型开始加载 回调')
+        },
+        (res) => {},
+        {
+          flyto: true,
+          maxspaceerror: 0.3,
+        }
+      )
+    },
   },
 }
 </script>

+ 30 - 17
src/views/modelView/MoldClosingPage.vue

@@ -171,15 +171,7 @@ export default {
       if (this.gisList.children.length > 0) {
         window.api.Public.setGisState(true)
       }
-      //设置gis地图
-      window.api.Public.AddImageryProvider(
-        'https://mapapi.geodata.gov.hk/gs/api/v1.0.0/xyz/imagery/WGS84/{z}/{x}/{y}.png',
-        true,
-        {
-          serverType: 0,
-          maximumLevel: 19,
-        }
-      )
+      this.loadHKMap()
     }
   },
   beforeDestroy() {
@@ -459,16 +451,13 @@ export default {
           this.cadList.children[modelindex] = detail
         }
       }
-      this.treeData[0].children = [...this.treeData[0].children ]
+      this.treeData[0].children = [...this.treeData[0].children]
       this.$message.success(this.$t('save.ok'))
     },
     resetModel(detail) {
-      window.api.Model.setModelMatrix(
-        detail.lightweightName,
-        window.Cesium.Matrix4.IDENTITY
-      );
-      window.api.viewer.scene.requestRender();
-      window.api.Model.location(detail.lightweightName);
+      window.api.Model.setModelMatrix(detail.lightweightName, window.Cesium.Matrix4.IDENTITY)
+      window.api.viewer.scene.requestRender()
+      window.api.Model.location(detail.lightweightName)
       this.initOffset(detail)
       this.initRotate(detail)
     },
@@ -495,7 +484,31 @@ export default {
       options.point2 = point2Z
       options.rotate = modelInfo.rotate.z
       window.api.Model.rotateByAnyAxis(options)
-    }
+    },
+    loadHKMap() {
+      //设置gis地图
+      window.api.Public.AddImageryProvider(
+        'https://mapapi.geodata.gov.hk/gs/api/v1.0.0/xyz/imagery/WGS84/{z}/{x}/{y}.png',
+        true,
+        {
+          serverType: 0,
+          maximumLevel: 19,
+        }
+      )
+      //加载建筑模型
+      window.api.Model.mergeModel(
+        'https://data1.map.gov.hk/api/3d-data/3dtiles/f2/tileset.json?key=3967f8f365694e0798af3e7678509421',
+        'hkBuilding',
+        (res) => {
+          console.log('模型开始加载 回调')
+        },
+        (res) => {},
+        {
+          flyto: true,
+          maxspaceerror: 0.3,
+        }
+      )
+    },
   },
 }
 </script>