月球大数据地理空间分析展示平台-【前端】-月球2期前端
Surpriseplus
2023-07-07 3c23ce2d0214a1246664e61fd51466033e25481e
src/assets/js/Map/menuTool.js
@@ -1,16 +1,17 @@
import * as turf from "@turf/turf";
const menuTool = {
  toolMenu: null,
  toolFlag: null,
  oldLeftMenuId: null,
  colorAll: {},
  squareOjb: [],
  colorAll: {
    point: SmartEarth.Cesium.Color.fromCssColorString("#ff0000"),
    polyline: SmartEarth.Cesium.Color.fromCssColorString("#ffff0050"),
    polygon: SmartEarth.Cesium.Color.fromCssColorString("#ffff0050"),
  },
  topTools(res) {
    // this.clearTopTools();
    // if (res.id == this.toolFlag) {
    //   this.toolFlag = null;
    //   return;
    // }
    this.toolFlag = res.id;
    switch (res.id) {
      case "a2": //点漫游
@@ -59,11 +60,46 @@
      case "e1"://快照
        this.snapshot();
        break;
      case "f1"://空间查询
        this.spatialQuery();
        break;
      case "g1": //坐标定位
        this.Coordposition();
        break;
    }
  },
  //空间查询
  spatialQuery() {
    sgworld.Creator.createSimpleGraphic('rectangle', { showSize: false }, (entity) => {
      var west = Cesium.Math.toDegrees(
        entity.rectangle._coordinates.getValue().west
      ); // 根据弧度获取到经度
      var east = Cesium.Math.toDegrees(
        entity.rectangle._coordinates.getValue().east
      ); // 根据弧度获取到纬度
      var north = Cesium.Math.toDegrees(
        entity.rectangle._coordinates.getValue().north
      ); // 根据弧度获取到经度
      var south = Cesium.Math.toDegrees(
        entity.rectangle._coordinates.getValue().south
      ); // 根据弧度获取到纬度
      sgworld.Creator.SimpleGraphic.clear();
      var polygon = turf.polygon([
        [
          [east, north],
          [west, north],
          [west, south],
          [east, south],
          [east, north],
        ],
      ]);
      debugger
    });
  },
  //快照
  snapshot() {
    let canvas = window.Viewer.scene.canvas;
    let image = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream");
@@ -217,40 +253,26 @@
  },
  //垂直高度
  verticalHeight() {
    earthCtrl.measure.measureHeight(function (e) { });
    sgworld.Analysis.verticalHeight(this.colorAll, () => {
    });
  },
  //高程测量
  heightMeasure() {
    var colorAll = {
      point: Cesium.Color.fromCssColorString("#ff0000"),
      polyline: Cesium.Color.fromCssColorString("#ffff0050"),
      polygon: Cesium.Color.fromCssColorString("#ffff0050"),
    };
    earthCtrl.Analysis.altitude(colorAll, () => { });
    earthCtrl.Analysis.altitude(this.colorAll, () => { });
  },
  //平面面积
  planeDistance() {
    // earthCtrl.analysis.getPlaneArea(function (e) { });
    var colorAll = {
      point: Cesium.Color.fromCssColorString("#ff0000"),
      polyline: Cesium.Color.fromCssColorString("#ffff0050"),
      polygon: Cesium.Color.fromCssColorString("#ffff0050"),
    };
    sgworld.Analysis.planeArea(colorAll, () => {
    sgworld.Analysis.planeArea(this.colorAll, () => {
    });
  },
  //表面距离
  surfaceDistance() {
    // earthCtrl.analysis.getDistanceHorizontal(function (e) {
    //   console.info(e);
    // });
    var colorAll = {
      point: Cesium.Color.fromCssColorString("#ff0000"),
      polyline: Cesium.Color.fromCssColorString("#ffff0050"),
      polygon: Cesium.Color.fromCssColorString("#ffff0050"),
    };
    sgworld.Analysis.horizontalDistance(colorAll, () => {
    sgworld.Analysis.horizontalDistance(this.colorAll, () => {
    });
  },
  //点漫游
@@ -283,7 +305,8 @@
  },
  //清除按钮
  clearALL(id) {
    id.forEach((e) => {
    debugger
    id.value.forEach((e) => {
      this.clearTopTools(e);
    });
  },
@@ -295,35 +318,25 @@
          break;
        case "a3":
          break;
        case "b2":
          earthCtrl.tools.browse();
          break;
        case "b3":
          earthCtrl.analysis.deleteObject();
        case "b4":
          earthCtrl.Analysis.clearMeasure();
        case "b5":
          earthCtrl.tools.browse();
        case "b2"://距离测量
        case "b3"://面积测量
        case "b4"://高程测量
        case "b5"://高度测量
          sgworld.Analysis.clearMeasure()
          break;
        case "c2": //点
          earthCtrl.Creator.SimpleGraphic.clear();
          break;
        case "c3": //文字
          earthCtrl.Creator.SimpleGraphic.clear();
          break;
        case "c4": //线
          earthCtrl.Creator.SimpleGraphic.clear();
          break;
        case "c5": //矩形
          earthCtrl.Creator.SimpleGraphic.clear();
          break;
        case "c6": //多边形
          earthCtrl.Creator.SimpleGraphic.clear();
          sgworld.Creator.SimpleGraphic.clear();
          break;
        case "d5":
          debugger;
          this.toolMenu.removeFromMap();
          break;
        case 'f1':
          sgworld.Creator.SimpleGraphic.clear();
          break;
      }
      // this.toolFlag = null;
      this.toolMenu = null;