月球大数据地理空间分析展示平台-【前端】-月球2期前端
surprise
2024-03-01 12075d0fa73d963ff5d6dbc4727fb95fb6084961
src/assets/js/Map/menuTool.js
@@ -6,6 +6,7 @@
// import { Store } from "vuex";
import store from "@/store";
import temporaryTool from "./temporaryTools";
import { getToken } from "@/utils/auth";
const menuTool = {
  toolMenu: null,
  toolFlag: null,
@@ -21,6 +22,7 @@
  exportSquare: null,
  imageryProvider: null,
  legendBox: null,
  Point1: false,
  topTools(res) {
    this.toolFlag = res.id;
@@ -172,10 +174,19 @@
    });
  },
  getLayrUrl(res) {
    var url;
    if (res.indexOf('{token}')>-1) {
      const token = getToken();
      url = config.proxy + res.replaceAll("{token}", token);
    } else {
      url = res;
    }
    return url;
  },
  addTMSLayer(obj) {
    var esri = new Cesium.WebMapServiceImageryProvider({
      url: config.esri,
      name: 'esriLayer',
@@ -643,6 +654,8 @@
    window.rightViewer.imageryLayers.removeAll();
    window.rightViewer = DoubleScreen.right._Viewer;
    window.rightViewer.animation.container.style.visibility = "hidden";
    window.rightViewer.scene.sun.show = false; //隐藏太阳和月亮
    window.rightViewer.scene.moon.show = false;
    // window.rightViewer.timeline.container.style.visibility = "hidden";
    //大气层
    window.rightViewer.scene.globe.showGroundAtmosphere = false;
@@ -698,7 +711,118 @@
  },
  //点漫游
  pointRoam() {
    earthCtrl.Analysis.setPointFly();
    store.state.menuFlag = "pointRoam"
    Viewer.scene.globe.depthTestAgainstTerrain = true;
    let tooltip = earthCtrl.Core.CreateTooltip();
    let isFly = false, PointFly;
    let distance = 2000 //设置距离选择点观察的初始高度
    //设置鼠标样式
    earthCtrl.Core.mouse(earthCtrl.Viewer.container, 1, SmartEarthRootUrl + 'Workers/image/cursor/draw.cur');
    const pickHandler = new Cesium.ScreenSpaceEventHandler(earthCtrl.Viewer.scene.canvas);
    const end = () => {
      //提示词关闭
      tooltip.show(false);
      pickHandler && pickHandler.destroy();
      //鼠标样式恢复
      earthCtrl.Core.mouse(earthCtrl.Viewer.container, 0);
      PointFly.end(); //移除旋转视角飞行
    }
    const fly = (degree) => {
      const duration = 3 // 从起始点飞到选择的点位时间
      //回调绕飞
      const callback = function () {
        PointFly = earthCtrl.Analysis.setPointFly({
          position: Cesium.Cartesian3.fromDegrees(degree.lon, degree.lat, degree.height+2000),
          distance: distance,
        })
      }
      earthCtrl.camera.flyTo(degree.lon, degree.lat, 100000, 0, -90, 0, duration, callback)
    }
    pickHandler.setInputAction(function (movement) {
      if (!isFly) {
        tooltip.showAt(movement.position, '点击结束绕飞');
        isFly = true;
        let degree = earthCtrl.Navigate.getMouseDegrees(movement);
        fly(degree)
      } else {
        end();
      }
    }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
    pickHandler.setInputAction(function (movement) {
      !isFly && tooltip.showAt(movement.endPosition, '点击选择定位点');
      isFly && tooltip.showAt(movement.endPosition, '点击结束绕飞');
    }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
    pickHandler.setInputAction(function (movement) {
      distance -= movement * distance / 300;
      distance < 1 && (distance = 1);
      PointFly.distance = distance
    }, Cesium.ScreenSpaceEventType.WHEEL);
    // earthCtrl.Analysis.setPointFly({distance:5000});
    // earthCtrl.measure.pickPosition({}, (e) => {
    //   Viewer.scene.globe.depthTestAgainstTerrain = false;
    //   const lon = e.result.longitude
    //   const lat = e.result.latitude
    //   const alt = e.result.alt
    //   const hei = 10000 //飞行到点位的高度
    //   const heading = 0
    //   const pitch = -90
    //   const roll = 0
    //   const duration = 3 //飞行时间
    //   //标记选择的点位为红点
    //   const Point1 = earthCtrl.factory.createPoint({
    //     id: earthCtrl.factory.createUUID(),
    //     name: '点击的点',
    //     lon: lon,
    //     lat: lat,
    //     alt: 300,
    //     pixelSize: 15,
    //     color: SmartEarth.Cesium.Color.fromCssColorString("#ff0000"),
    //     outlineColor: SmartEarth.Cesium.Color.BLACK,
    //     outlineWidth: 1,
    //   });
    //  this.Point1 =  earthCtrl.factory.createBillboard({
    //     name: "标签点",
    //     id: earthCtrl.factory.createUUID(),
    //     image:imageUrl+"/img/mark.png",
    //     width:16,
    //     height:22,
    //     lon: lon,
    //     lat: lat,
    //     alt: 10,
    //     scale: 1.5,
    // });
    //   //回调绕飞
    //   const callback = () => {
    //     earthCtrl.tools.clearTool();//结束拾取
    //     const useTime = 5 //单位秒
    //     //旋转绕飞
    //     const roate = earthCtrl.camera.rotateCamera({
    //       lon: lon,
    //       lat: lat,
    //       distance: hei,
    //       pitch: -30,
    //       time: useTime
    //     })
    //     const timeout = setTimeout(() => {
    //       roate.removeFromMap(); //移除旋转视角锁定
    //       clearTimeout(timeout)
    //       this.Point1.removeFromMap()
    //     }, useTime * 1000);
    //   }
    //   //飞行
    //   earthCtrl.camera.flyTo(lon, lat, hei, heading, pitch, roll, duration, callback)
    // })
  },
  //线漫游
  lineRoam() {