月球大数据地理空间分析展示平台-【前端】-月球2期前端
src/assets/js/Map/menuTool.js
@@ -7,10 +7,10 @@
  squareOjb: [],
  topTools(res) {
    // this.clearTopTools();
    if (res.id == this.toolFlag) {
      this.toolFlag = null;
      return;
    }
    // if (res.id == this.toolFlag) {
    //   this.toolFlag = null;
    //   return;
    // }
    this.toolFlag = res.id;
    switch (res.id) {
      case "a2": //点漫游
@@ -46,18 +46,47 @@
      case "c6": //多边形
        this.createSimpleGraphic("polyhedron");
        break;
      case "d2"://等高线分析
        break
      case "d3"://坡度分析
        break
      case "d4": //土方量计算
        this.Volumetric();
        break;
      case "d5": //影像对比
        this.CurtainContrast();
        break;
      case "e1"://快照
        this.snapshot();
        break;
      case "g1": //坐标定位
        this.Coordposition();
        break;
    }
  },
  snapshot() {
    let canvas = window.Viewer.scene.canvas;
    let image = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream");
    let link = document.createElement("a");
    let blob = this.dataURLtoBlob(image);
    let objurl = URL.createObjectURL(blob);
    link.download = "scene.png";
    link.href = objurl;
    link.click();
  },
  dataURLtoBlob(dataurl) {
    let arr = dataurl.split(','),
      mime = arr[0].match(/:(.*?);/)[1],
      bstr = atob(arr[1]),
      n = bstr.length,
      u8arr = new Uint8Array(n);
    while (n--) {
      u8arr[n] = bstr.charCodeAt(n);
    }
    return new Blob([u8arr], { type: mime });
  },
  leftTools(res) {
    this.clearLeftTools(res);
@@ -100,6 +129,7 @@
  },
  // 矩形正方形
  createRectangle(entity) {
    this.delRectangle();
    var west = Cesium.Math.toDegrees(
      entity.rectangle._coordinates.getValue().west
    ); // 根据弧度获取到经度
@@ -148,6 +178,11 @@
    this.squareOjb.push(e);
    // earthCtrl.Creator.SimpleGraphic.clear();
    Viewer.entities.remove(entity);
    debugger
    window.functionForJs({
      type: 'exportMap',
      value: true
    })
  },
  // 创建图形
  createSimpleGraphic(type, scene) {
@@ -166,7 +201,7 @@
  },
  //坐标定位
  Coordposition() {},
  Coordposition() { },
  //影像对比
  CurtainContrast() {
    this.toolMenu = earthCtrl.analysis.createCurtainContrast({
@@ -181,7 +216,7 @@
  },
  //垂直高度
  verticalHeight() {
    earthCtrl.measure.measureHeight(function (e) {});
    earthCtrl.measure.measureHeight(function (e) { });
  },
  //高程测量
  heightMeasure() {
@@ -190,11 +225,11 @@
      polyline: Cesium.Color.fromCssColorString("#ffff0050"),
      polygon: Cesium.Color.fromCssColorString("#ffff0050"),
    };
    earthCtrl.Analysis.altitude(colorAll, () => {});
    earthCtrl.Analysis.altitude(colorAll, () => { });
  },
  //平面面积
  planeDistance() {
    earthCtrl.analysis.getPlaneArea(function (e) {});
    earthCtrl.analysis.getPlaneArea(function (e) { });
  },
  //表面距离
  surfaceDistance() {
@@ -278,6 +313,6 @@
      this.toolMenu = null;
    }
  },
  clearLeftTools(res) {},
  clearLeftTools(res) { },
};
export default menuTool;