月球大数据地理空间分析展示平台-【前端】-月球2期前端
surprise
2023-10-19 9f51306b10520a2be30bedfe1b34c288cf770f43
src/components/mouseMove.vue
@@ -1,13 +1,6 @@
<template>
  <div
    class="mouseBox"
    @setMouseMove="setMouseMove"
  >
    <div
      class="earthImage"
      :class="{ active: gridIsshow }"
      @click="gridSwitch"
    ></div>
  <div class="mouseBox" @setMouseMove="setMouseMove">
    <div class="earthImage" :class="{ active: gridIsshow }" @click="gridSwitch"></div>
    <div class="earthLable">经度 :</div>
    <div class="earthLable">{{ longitude }}</div>
    <div class="earthLable">纬度 :</div>
@@ -56,13 +49,15 @@
  let handlerPoint = new SmartEarth.Cesium.ScreenSpaceEventHandler(
    window.Viewer.scene.canvas
  );
  const pickGlobeSlope = new SmartEarth.Cesium.PickGlobeSlope(earthCtrl.Viewer)
  var ellipsoid = window.Viewer.scene.globe.ellipsoid;
  handlerPoint.setInputAction(function (movement) {
  handlerPoint.setInputAction((movement) => {
    //捕获椭球体,将笛卡尔二维平面坐标转为椭球体的笛卡尔三维坐标,返回球体表面的点
    var cartesian = window.Viewer.camera.pickEllipsoid(
      movement.endPosition,
      ellipsoid
    );
    if (cartesian) {
      //将笛卡尔三维坐标转为地图坐标(弧度)
      var cartographic =
@@ -119,27 +114,27 @@
  });
   Viewer.scene.postRender.addEventListener(() => {
      // // 获取画布的大小
      let scene = earthCtrl.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));
  Viewer.scene.postRender.addEventListener(() => {
    // // 获取画布的大小
    let scene = earthCtrl.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 leftPosition = scene.globe.pick(left, scene);
      var rightPosition = scene.globe.pick(right, scene);
      if (!SmartEarth.Cesium.defined(leftPosition) || !SmartEarth.Cesium.defined(rightPosition)) {
        return;
      }
      const ellipsoid = SmartEarth.Cesium.Ellipsoid.MOON2000
      var leftCartographic = ellipsoid.cartesianToCartographic(leftPosition);
      var rightCartographic = ellipsoid.cartesianToCartographic(rightPosition);
      var geodesic = new SmartEarth.Cesium.EllipsoidGeodesic(leftCartographic, rightCartographic, ellipsoid);
      var distance = geodesic.surfaceDistance;// 分辨率
      rate.value =distance.toFixed(2); //分辨率
    })
    var leftPosition = scene.globe.pick(left, scene);
    var rightPosition = scene.globe.pick(right, scene);
    if (!SmartEarth.Cesium.defined(leftPosition) || !SmartEarth.Cesium.defined(rightPosition)) {
      return;
    }
    const ellipsoid = SmartEarth.Cesium.Ellipsoid.MOON2000
    var leftCartographic = ellipsoid.cartesianToCartographic(leftPosition);
    var rightCartographic = ellipsoid.cartesianToCartographic(rightPosition);
    var geodesic = new SmartEarth.Cesium.EllipsoidGeodesic(leftCartographic, rightCartographic, ellipsoid);
    var distance = geodesic.surfaceDistance;// 分辨率
    rate.value = distance.toFixed(2); //分辨率
  })
};
const gridSwitch = () => {
  server.showlonlatLine();
@@ -303,6 +298,7 @@
  padding-right: 20px;
  display: flex;
  align-items: center;
  .earthImage {
    width: 20px;
    height: 20px;
@@ -311,6 +307,7 @@
    margin-left: 10px;
    cursor: pointer;
  }
  .earthLable {
    font-size: 16px;
    font-family: Source Han Sans CN;
@@ -319,6 +316,7 @@
    line-height: 5px;
    margin-left: 10px;
  }
  .active {
    background-color: #171e2e;
    border: 1px solid;