月球大数据地理空间分析展示平台-【前端】-月球2期前端
Surpriseplus
2023-09-11 48a6eb2109a41f8e10d5a2b67ea17899d3ef3586
src/assets/js/Map/menuTool.js
@@ -1,7 +1,7 @@
import * as turf from "@turf/turf";
import WKT from "terraformer-wkt-parser";
import rightServer from "./rightServer";
import config from "./config";
// import config from "../../../../public/config/config";
import CryptoJS from "crypto-js";
// import { Store } from "vuex";
import store from "@/store";
@@ -17,6 +17,7 @@
    polyline: SmartEarth.Cesium.Color.fromCssColorString("#ffff0050"),
    polygon: SmartEarth.Cesium.Color.fromCssColorString("#ffff0050"),
  },
  exportSquare: null,
  topTools(res) {
    this.toolFlag = res.id;
    switch (res.id) {
@@ -103,24 +104,40 @@
    if (this.localPoint) {
      this.setLocalPositionClose();
    }
    var position = {
      X: parseFloat(res.lon),
      Y: parseFloat(res.lat),
      Altitude: parseFloat(res.alt),
    };
    this.localPoint = window.sgworld.Creator.CreateImageLabel(
      position,
      config.StaticFileBaseUrl + "/Workers/image/mark.png",
      {},
      0,
      "标签点"
    );
    var id = this.localPoint.item.id;
    window.sgworld.Navigate.flyToObj(this.localPoint.item);
    // var position = {
    //   X: parseFloat(res.lon),
    //   Y: parseFloat(res.lat),
    //   Altitude: parseFloat(res.alt),
    // };
    // this.localPoint = window.sgworld.Creator.CreateImageLabel(
    //   position,
    //   config.StaticFileBaseUrl + "/Workers/image/mark.png",
    //   {},
    //   0,
    //   "标签点"
    // );
    // var id = this.localPoint.item.id;
    // window.sgworld.Navigate.flyToObj(this.localPoint.item);
    this.localPoint = window.Viewer.entities.add({
      name: '坐标定位',
      position: Cesium.Cartesian3.fromDegrees(parseFloat(res.lon), parseFloat(res.lat), res.alt == null ? parseFloat(res.alt) : 0),
      billboard: {
        image: config.StaticFileBaseUrl + '/Workers/image/location.png',
        // 设置贴地
        heightReference: Cesium.Color.CORNFLOWERBLUE.withAlpha(0.4),
        verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
        scale: 5.0,
      },
    });
    this.setViewerFlyTo(this.localPoint)
  },
  setLocalPositionClose() {
    this.localPoint.deleteObject();
    this.localPoint = null;
    if (this.localPoint) {
      // this.localPoint.deleteObject();
      window.Viewer.entities.remove(this.localPoint)
      this.localPoint = null;
    }
  },
  //坡度分析
  setSlopeMap() {
@@ -135,7 +152,7 @@
      fabric: {
        type: "ElevationRamp",
        uniforms: {
          image: config.StaticFileBaseUrl + "/Assets/Images/color.png",
          image: config.StaticFileBaseUrl + "Assets/Images/color.png",
          minimumHeight: -10000,
          maximumHeight: 10000,
        },
@@ -309,6 +326,7 @@
      case "l3": //在线制图
        store.state.isShowMap = true;
        this.setThematicMap();
        break;
      case "l4":
        store.state.isShowMap = true;
@@ -323,11 +341,17 @@
  },
  thematicTools(res) {
    switch (res.id) {
      case "t1":
        store.state.setLayerManager = !store.state.setLayerManager;
        break;
      case "t2":
        this.createSimpleGraphic("rectangle", "square");
        break;
      case "t3":
        this.delRectangle();
        break;
      case "t4":
        store.state.setExportList = !store.state.setExportList
        break;
    }
  },
@@ -359,7 +383,11 @@
    var east1 = ss[2];
    var north1 = ss[3];
    var south1 = ss[1];
    this.exportSquare = ss;
    var geometry = Cesium.Rectangle.fromDegrees(west1, south1, east1, north1);
    Viewer.camera.setView({
      destination: Cesium.Rectangle.fromDegrees(west, south, east, north),
    });
@@ -387,6 +415,7 @@
    // var handle = new SmartEarth.Cesium.ScreenSpaceEventHandler(
    //   earthCtrl.viewer.scene.canvas
    // );
  },
  //坐标定位
@@ -422,6 +451,7 @@
    window.rightViewer.scene.skyAtmosphere.show = false;
    const compass = document.getElementsByClassName("bottom_btn")[0];
    compass.style.right = "calc(50% + 70px)";
    compass.style.positions = "absolute";
    store.state.doubleMap = true;
    setTimeout(() => {
      window.functionGetLayer({
@@ -545,7 +575,7 @@
  //空间查询属性定位
  spaceLocation(res) {
    var name = '空间查询';
    debugger
    this.setClearLocation(name);
    switch (res.type) {
      case 'MultiPolygon':
@@ -590,10 +620,7 @@
        outlineColor: Cesium.Color.DODGERBLUE,
      }
    });
    window.Viewer.flyTo(locationPolygonEntity, {
      duration: 5,
      offset: new SmartEarth.Cesium.HeadingPitchRange(0.0, SmartEarth.Cesium.Math.toRadians(-20.0))
    });
    this.setViewerFlyTo(locationPolygonEntity)
  },
  setLocationPoint(res, name) {
    const position = window.Viewer.entities.add({
@@ -607,11 +634,21 @@
        scale: 5.0,
      },
    });
    window.Viewer.flyTo(position, {
      duration: 5,
      offset: new SmartEarth.Cesium.HeadingPitchRange(0.0, SmartEarth.Cesium.Math.toRadians(-20.0))
    this.setViewerFlyTo(position)
  },
  setViewerFlyTo(entity) {
    window.Viewer.flyTo(entity, {
      offset: {
        heading: Cesium.Math.toRadians(0.0),
        pitch: Cesium.Math.toRadians(-45),
        range: 40000
      }
    });
  },
  setLocationLine(res, name) {
    var position = [];
@@ -632,10 +669,7 @@
      },
    })
    window.Viewer.flyTo(polyline, {
      duration: 5,
      offset: new SmartEarth.Cesium.HeadingPitchRange(0.0, SmartEarth.Cesium.Math.toRadians(-20.0))
    });
    this.setViewerFlyTo(polyline)
  }
};