月球大数据地理空间分析展示平台-【前端】-月球2期前端
WX
2023-09-13 3ac241dca10f0dc85b6a3291a8339f1b1765491f
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: 1.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,12 +152,14 @@
      fabric: {
        type: "ElevationRamp",
        uniforms: {
          image: config.StaticFileBaseUrl + "Assets/Images/color.png",
          image: config.StaticFileBaseUrl + "Assets/Images/colors75.png",
          minimumHeight: -10000,
          maximumHeight: 10000,
        },
      },
    });
    Viewer.scene.globe.material = window.material;
  },
@@ -309,6 +328,7 @@
      case "l3": //在线制图
        store.state.isShowMap = true;
        this.setThematicMap();
        break;
      case "l4":
        store.state.isShowMap = true;
@@ -323,11 +343,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 +385,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 +417,7 @@
    // var handle = new SmartEarth.Cesium.ScreenSpaceEventHandler(
    //   earthCtrl.viewer.scene.canvas
    // );
  },
  //坐标定位
@@ -422,6 +453,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 +577,7 @@
  //空间查询属性定位
  spaceLocation(res) {
    var name = '空间查询';
    debugger
    this.setClearLocation(name);
    switch (res.type) {
      case 'MultiPolygon':
@@ -601,13 +633,14 @@
        // 设置贴地
        heightReference: Cesium.Color.CORNFLOWERBLUE.withAlpha(0.4),
        verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
        scale: 5.0,
        scale: 1.0,
      },
    });
    this.setViewerFlyTo(position)
  },
  setViewerFlyTo(entity) {
    window.Viewer.flyTo(entity, {
      offset: {
        heading: Cesium.Math.toRadians(0.0),