From 545e343b7ec25fcc95d5a43727c9ebfbd4576b5e Mon Sep 17 00:00:00 2001
From: Surpriseplus <845948745@qq.com>
Date: 星期五, 18 八月 2023 10:54:20 +0800
Subject: [PATCH] 图层管理修改,空间查询修改,鼠标移动显示经纬度修改

---
 src/components/mouseMove.vue |   68 ++++++++++++++++------------------
 1 files changed, 32 insertions(+), 36 deletions(-)

diff --git a/src/components/mouseMove.vue b/src/components/mouseMove.vue
index e1fc7ae..dd80289 100644
--- a/src/components/mouseMove.vue
+++ b/src/components/mouseMove.vue
@@ -12,6 +12,9 @@
     <div class="earthLable">{{ longitude }}</div>
     <div class="earthLable">绾害 :</div>
     <div class="earthLable">{{ latitude }}</div>
+    <div class="earthLable">鍦板舰楂樺害 :</div>
+    <div class="earthLable">{{ altHeight }} </div>
+    <div class="earthLable">绫�</div>
     <div class="earthLable">瑙嗚楂樺害 :</div>
     <div class="earthLable">{{ alt }} </div>
     <div class="earthLable">鍗冪背</div>
@@ -34,7 +37,7 @@
 const latitude = ref("0.00");
 const rate = ref("0.00");
 const alt = ref("0.00");
-const alheight = ref("0.00");
+const altHeight = ref("0.00");
 
 let entitiesObj = reactive({
   lonLine: [],
@@ -69,31 +72,12 @@
       latitude.value = SmartEarth.Cesium.Math.toDegrees(
         cartographic.latitude
       ).toFixed(6);
-
-      let scene = window.Viewer.scene;
-      // 鑾峰彇鐢诲竷鐨勫ぇ灏�
-      var width = scene.canvas.clientWidth;
-      var height = scene.canvas.clientHeight;
-      //鑾峰彇鐢诲竷涓績涓や釜鍍忕礌鐨勫潗鏍囷紙榛樿鍦板浘娓叉煋鍦ㄧ敾甯冧腑蹇冧綅缃級
-      var left = scene.camera.getPickRay(
-        new SmartEarth.Cesium.Cartesian2((width / 2) | 0, (height - 1) / 2)
+      altHeight.value = window.Viewer.scene.globe.getHeight(
+        Cesium.Cartographic.fromDegrees(longitude.value, latitude.value, 0)
       );
-      var right = scene.camera.getPickRay(
-        new SmartEarth.Cesium.Cartesian2((1 + width / 2) | 0, (height - 1) / 2)
-      );
-      var globe = scene.globe;
-      var leftPosition = globe.pick(left, scene);
-      var rightPosition = globe.pick(right, scene);
-      if (!Cesium.defined(leftPosition) || !Cesium.defined(rightPosition)) {
-        return;
+      if (altHeight.value) {
+        altHeight.value = altHeight.value.toFixed(6);
       }
-      var leftCartographic =
-        globe.ellipsoid.cartesianToCartographic(leftPosition);
-      var rightCartographic =
-        globe.ellipsoid.cartesianToCartographic(rightPosition);
-      var geodesic = new SmartEarth.Cesium.EllipsoidGeodesic();
-      geodesic.setEndPoints(leftCartographic, rightCartographic);
-      rate.value = geodesic.surfaceDistance.toFixed(6); //鍒嗚鲸鐜�
     }
   }, SmartEarth.Cesium.ScreenSpaceEventType.MOUSE_MOVE);
 
@@ -103,18 +87,30 @@
       2
     );
     alt.value = camera_alt;
-    // // 鏂逛綅瑙�
-    // let heading = Cesium.Math.toDegrees(viewer.camera.heading).toFixed(2);
-    // // 淇话瑙�
-    // let pitch = Cesium.Math.toDegrees(viewer.camera.pitch).toFixed(2);
-    // // 缈绘粴瑙�
-    // let roll = Cesium.Math.toDegrees(viewer.camera.roll).toFixed(2);
-    // // 绾у埆
-    // let level = 0;
-    // let tileRender = viewer.scene._globe._surface._tilesToRender;
-    // if (tileRender && tileRender.length > 0) {
-    //   level = viewer.scene._globe._surface._tilesToRender[0]._level;
-    // }
+    let scene = window.Viewer.scene;
+    // 鑾峰彇鐢诲竷鐨勫ぇ灏�
+    var width = scene.canvas.clientWidth;
+    var height = scene.canvas.clientHeight;
+    //鑾峰彇鐢诲竷涓績涓や釜鍍忕礌鐨勫潗鏍囷紙榛樿鍦板浘娓叉煋鍦ㄧ敾甯冧腑蹇冧綅缃級
+    var left = scene.camera.getPickRay(
+      new SmartEarth.Cesium.Cartesian2((width / 2) | 0, (height - 1) / 2)
+    );
+    var right = scene.camera.getPickRay(
+      new SmartEarth.Cesium.Cartesian2((1 + width / 2) | 0, (height - 1) / 2)
+    );
+    var globe = scene.globe;
+    var leftPosition = globe.pick(left, scene);
+    var rightPosition = globe.pick(right, scene);
+    if (!Cesium.defined(leftPosition) || !Cesium.defined(rightPosition)) {
+      return;
+    }
+    var leftCartographic =
+      globe.ellipsoid.cartesianToCartographic(leftPosition);
+    var rightCartographic =
+      globe.ellipsoid.cartesianToCartographic(rightPosition);
+    var geodesic = new SmartEarth.Cesium.EllipsoidGeodesic();
+    geodesic.setEndPoints(leftCartographic, rightCartographic);
+    rate.value = geodesic.surfaceDistance.toFixed(6); //鍒嗚鲸鐜�
   });
 };
 const gridSwitch = () => {

--
Gitblit v1.9.3