瀏覽代碼

添加学区定位逻辑

DESKTOP-6LTVLN7\Liumouren 9 月之前
父節點
當前提交
6a137cd22c
共有 1 個文件被更改,包括 26 次插入29 次删除
  1. 26 29
      src/components/Schools.vue

+ 26 - 29
src/components/Schools.vue

@@ -161,19 +161,19 @@ export default {
     flytoSchoolDataToMap(data) {
       let that = this;
       // 首先判断是否存在
-      if (this.mapWallEntity[data.title]) {
-        // 先删除其他的
-        this.mapWallEntity[data.title].forEach((item) => {
-          item.show = false;
-        });
-        if (viewer.dataSources) {
-          viewer.dataSources.forEach((item) => {
-            viewer.dataSources.remove(item);
-          });
-        }
-        this.geojsonDataSource[item.id] = null;
-        delete this.geojsonDataSource[item.id];
-      }
+      // if (this.mapWallEntity[data.title]) {
+      //   // 先删除其他的
+      //   this.mapWallEntity[data.title].forEach((item) => {
+      //     item.show = false;
+      //   });
+      //   if (viewer.dataSources) {
+      //     viewer.dataSources.forEach((item) => {
+      //       viewer.dataSources.remove(item);
+      //     });
+      //   }
+      //   this.geojsonDataSource[item.id] = null;
+      //   delete this.geojsonDataSource[item.id];
+      // }
       // 不存在的话要新建并定位
       // 添加围墙
       this.mapWallEntity[data.title] = [];
@@ -251,26 +251,23 @@ export default {
         },
         data.title
       );
+      // 定位
+      viewer.camera.setView({
+        destination: SkyScenery.Cartesian3.fromDegrees(
+          data.c_latlon.split(",")[0],
+          data.c_latlon.split(",")[1],
+          3000
+        ), // 设置位置
+        orientation: {
+          heading: SkyScenery.Math.toRadians(356.03124515798294), // 方向
+          pitch: SkyScenery.Math.toRadians(-90), // 倾斜角度
+          roll: SkyScenery.Math.toRadians(0.0047792745453184024),
+        },
+      });
     },
 
     // 加载geojson数据
     addGeoJson(pointData, options, id) {
-      // options = {
-      //   point: {
-      //     imgUrl: ""
-      //   },
-      //   polyline: {
-      //     color: "#ffffff",
-      //     width: 3,
-      //     alpha: 0.7
-      //   },
-      //   polygon: {
-      //     outerColor: "#ffffff",
-      //     outerWidth: 3,
-      //     innerColor: "#ffffff",
-      //     alpha: 0.7
-      //   }
-      // };
       SkyScenery.GeoJsonDataSource.load(pointData).then(function (dataSource) {
         viewer.dataSources.add(dataSource);
         var entities = dataSource.entities.values;