From ffb95c5b73c2bf11cd66b3c05955833397dc553b Mon Sep 17 00:00:00 2001
From: WX <1377869194@qq.com>
Date: 星期五, 16 六月 2023 17:57:38 +0800
Subject: [PATCH] 部分功能添加完善

---
 src/assets/js/Map/menuTool.js |  182 ++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 169 insertions(+), 13 deletions(-)

diff --git a/src/assets/js/Map/menuTool.js b/src/assets/js/Map/menuTool.js
index 187f20c..59048c0 100644
--- a/src/assets/js/Map/menuTool.js
+++ b/src/assets/js/Map/menuTool.js
@@ -1,9 +1,12 @@
+import * as turf from "@turf/turf";
 const menuTool = {
   toolMenu: null,
   toolFlag: null,
+  oldLeftMenuId: null,
   colorAll: {},
+  squareOjb: [],
   topTools(res) {
-    this.clearTopTools();
+    // this.clearTopTools();
     if (res.id == this.toolFlag) {
       this.toolFlag = null;
       return;
@@ -28,6 +31,21 @@
       case "b5": //鍨傜洿楂樺害
         this.verticalHeight();
         break;
+      case "c2": //鐐�
+        this.createSimpleGraphic("point");
+        break;
+      case "c3": //鏂囧瓧
+        this.createSimpleGraphic("label");
+        break;
+      case "c4": //绾�
+        this.createSimpleGraphic("polyline");
+        break;
+      case "c5": //鐭╁舰
+        this.createSimpleGraphic("rectangle");
+        break;
+      case "c6": //澶氳竟褰�
+        this.createSimpleGraphic("polyhedron");
+        break;
       case "d4": //鍦熸柟閲忚绠�
         this.Volumetric();
         break;
@@ -39,8 +57,15 @@
         break;
     }
   },
+
   leftTools(res) {
-    this.clearLeftTools();
+    this.clearLeftTools(res);
+
+    if (this.oldLeftMenuId == "l3") {
+      earthCtrl.coreMap.scene.mode = SmartEarth.Cesium.SceneMode.SCENE3D;
+    }
+    this.oldLeftMenuId = res.id;
+
     switch (res.id) {
       case "l1":
         break;
@@ -57,11 +82,87 @@
         break;
     }
   },
+  thematicTools(res) {
+    switch (res.id) {
+      case "t2":
+        this.createSimpleGraphic("rectangle", "square");
+        break;
+      case "t3":
+        this.delRectangle();
+        break;
+    }
+  },
+  //鍒犻櫎姝f柟褰�
+  delRectangle() {
+    this.squareOjb.forEach((e) => {
+      Viewer.entities.remove(e);
+    });
+  },
+  // 鐭╁舰姝f柟褰�
+  createRectangle(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
+    ); // 鏍规嵁寮у害鑾峰彇鍒扮含搴�
 
+    var ss = turf.square([west, south, east, north]);
+    var west1 = ss[0];
+    var east1 = ss[2];
+    var north1 = ss[3];
+    var south1 = ss[1];
+    var geometry = Cesium.Rectangle.fromDegrees(west1, south1, east1, north1);
+
+    // var e = Viewer.entities.add({
+    //   name: "姝f柟",
+    //   polygon: {
+    //     hierarchy: geometry1,
+    //     //height : 100000,
+    //     material: Cesium.Color.RED,
+    //     outline: true,
+    //     outlineColor: Cesium.Color.RED,
+    //   },
+    // });
+    const stripeMaterial = new Cesium.StripeMaterialProperty({
+      evenColor: Cesium.Color.WHITE.withAlpha(0.5),
+      oddColor: Cesium.Color.BLUE.withAlpha(0.5),
+      repeat: 5.0,
+    });
+    var e = Viewer.entities.add({
+      rectangle: {
+        coordinates: geometry,
+        outline: true,
+        outlineColor: Cesium.Color.WHITE,
+        outlineWidth: 4,
+        stRotation: Cesium.Math.toRadians(45),
+        material: stripeMaterial,
+      },
+    });
+    this.squareOjb.push(e);
+    // earthCtrl.Creator.SimpleGraphic.clear();
+    Viewer.entities.remove(entity);
+  },
+  // 鍒涘缓鍥惧舰
+  createSimpleGraphic(type, scene) {
+    earthCtrl.Creator.createSimpleGraphic(type, {}, (entity) => {
+      if (scene === "square") {
+        this.createRectangle(entity);
+      }
+    });
+  },
   //鍦ㄧ嚎鍒跺浘
   setThematicMap() {
-    // earthCtrl.coreMap.scene.mode = SmartEarth.Cesium.SceneMode.SCENE2D;
-    // var handle = new SmartEarth.Cesium.ScreenSpaceEventHandler(earthCtrl.viewer.scene.canvas);
+    earthCtrl.coreMap.scene.mode = SmartEarth.Cesium.SceneMode.SCENE2D;
+    // var handle = new SmartEarth.Cesium.ScreenSpaceEventHandler(
+    //   earthCtrl.viewer.scene.canvas
+    // );
   },
 
   //鍧愭爣瀹氫綅
@@ -83,24 +184,62 @@
     earthCtrl.measure.measureHeight(function (e) {});
   },
   //楂樼▼娴嬮噺
-  heightMeasure() {},
+  heightMeasure() {
+    var colorAll = {
+      point: Cesium.Color.fromCssColorString("#ff0000"),
+      polyline: Cesium.Color.fromCssColorString("#ffff0050"),
+      polygon: Cesium.Color.fromCssColorString("#ffff0050"),
+    };
+    earthCtrl.Analysis.altitude(colorAll, () => {});
+  },
   //骞抽潰闈㈢Н
   planeDistance() {
     earthCtrl.analysis.getPlaneArea(function (e) {});
   },
   //琛ㄩ潰璺濈
   surfaceDistance() {
-    earthCtrl.measure.lineLength(function (e) {});
+    earthCtrl.analysis.getDistanceHorizontal(function (e) {
+      console.info(e);
+    });
   },
   //鐐规极娓�
-  pointRoam() {},
+  pointRoam() {
+    earthCtrl.Analysis.setPointFly();
+  },
   //绾挎极娓�
-  lineRoam() {},
-
+  lineRoam() {
+    earthCtrl.Command.execute(2, 3, "", (data) => {
+      data.showPoint = false;
+      data.showLine = true;
+      data.mode = 1;
+      // 寮圭獥鏁版嵁
+      window.PathAnimationData = {
+        flyData: data,
+      };
+      window.PathAnimationData.winIndex = layer.open({
+        type: 2,
+        title: "璺緞鍔ㄧ敾",
+        shade: false,
+        area: ["352px", "690px"],
+        offset: "r",
+        skin: "other-class",
+        content: SmartEarthRootUrl + "Workers/path/Path.html",
+        end: function () {
+          PathAnimationData.fly && PathAnimationData.fly.exit();
+        },
+      });
+    });
+  },
+  //娓呴櫎鎸夐挳
+  clearALL(id) {
+    id.forEach((e) => {
+      this.clearTopTools(e);
+    });
+  },
   //娓呴櫎鏂规硶
-  clearTopTools() {
-    if (this.toolFlag) {
-      switch (this.toolFlag) {
+  clearTopTools(id) {
+    if (id) {
+      switch (id) {
         case "a2":
           break;
         case "a3":
@@ -109,9 +248,26 @@
           earthCtrl.tools.browse();
           break;
         case "b3":
+          earthCtrl.analysis.deleteObject();
         case "b4":
+          earthCtrl.Analysis.clearMeasure();
         case "b5":
           earthCtrl.tools.browse();
+          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();
           break;
         case "d5":
           debugger;
@@ -122,6 +278,6 @@
       this.toolMenu = null;
     }
   },
-  clearLeftTools() {},
+  clearLeftTools(res) {},
 };
 export default menuTool;

--
Gitblit v1.9.3