From b1e9c826c1ba48c3dc263039699636ed2ba3be4e Mon Sep 17 00:00:00 2001
From: surprise <15810472099@163.com>
Date: 星期一, 27 十一月 2023 11:16:06 +0800
Subject: [PATCH] 版本更新,图层管理添加矢量数据下载,视角高度增加放大限制

---
 src/assets/js/Map/index.js |  140 ++++++++++++++++++++++++++++------------------
 1 files changed, 86 insertions(+), 54 deletions(-)

diff --git a/src/assets/js/Map/index.js b/src/assets/js/Map/index.js
index d6cc892..b424a0f 100644
--- a/src/assets/js/Map/index.js
+++ b/src/assets/js/Map/index.js
@@ -1,103 +1,135 @@
 //閰嶇疆鏂囦欢鍦板潃
-import config from "./config";
+// import config from "../../../../public/config/config";
 //鏈嶅姟鍔犺浇閰嶇疆鏂囦欢
+import { Store } from "vuex";
 import server from "./server";
-
+import store from "@/store";
 const InitMap = {
   earthCtrl: null,
   Viewer: null,
+  graticules: null,
   //鍦板浘鍒濆鍖�
   init3DMap() {
-    //璁剧疆鏈堢悆鍧愭爣绯�
+    SmartEarth.Cesium.ExternalParameter.eliminate = false;
+    SmartEarth.Cesium.ExternalParameter.changeApproximateTerrainHeights = true;
+    SmartEarth.Cesium.ExternalParameter.maxTerrainHeight = 2000000;
+    SmartEarth.Cesium.ExternalParameter.minTerrainHeight = -2000000;
+    SmartEarth.Cesium.ShadowMap.MAXIMUM_DISTANCE = 20000000000;
+    SmartEarth.Cesium.ExternalParameter.ellipsoidCoordinates = 'MOON2000'
+    window.Cesium = SmartEarth.Cesium;
     SmartEarth.Cesium.Ellipsoid.WGS84 = new SmartEarth.Cesium.Ellipsoid(
       1737400.0,
       1737400.0,
       1737400.0
     );
 
-    //璐村湴绾�
 
-    SmartEarth.Cesium.ExternalParameter.changeApproximateTerrainHeights = true;
     //椤甸潰鍒濆鍖�
     this.earthCtrl = new SmartEarth.EarthCtrl("cesiumContainer", {
       StaticFileBaseUrl: config.StaticFileBaseUrl,
-      ellipsoidCoordinates: "MOON",
+      ellipsoidCoordinates: 'MOON2000',
       timeline: true,
+      shadowBackCul1: false
     });
-
+    this.earthCtrl.Viewer.scene.debugShowFramesPerSecond = true
+    this.earthCtrl.coreMap.scene.screenSpaceCameraController.enableCollisionDetection = true;
+    this.earthCtrl.Viewer.scene.globe.terrainExaggeration = 1.00001
+    // this.earthCtrl.shadowMap.maximumDistance = 10000.0;
     window.earthCtrl = this.earthCtrl;
-
     window.Viewer = this.earthCtrl._Viewer;
-
     Viewer.scene.skyAtmosphere.show = false;
-
     window.Cesium = SmartEarth.Cesium;
-
     window.sgworld = earthCtrl;
+    sgworld.Creator.SimpleGraphic.edit(true, { editProp: false });
 
-    sgworld.Creator.SimpleGraphic.edit(true, { editProp: true });
+
+    // 鏈�灏忕缉鏀鹃珮搴︼紙绫筹級
+    Viewer.scene.screenSpaceCameraController.minimumZoomDistance =10000;
+    // 鏈�澶х缉鏀鹃珮搴︼紙绫筹級
+    Viewer.scene.screenSpaceCameraController.maximumZoomDistance = 5000000;
+
     //=======================
-    // window.Viewer.imageryLayers.removeAll();
+    //闃村奖鍒嗘瀽
+    Viewer.scene.globe.lightingFadeOutDistance = 5.8e+7;
+    Viewer.scene.globe.enableLighting = false;
+    earthCtrl.shadows = false;
+    //璁剧疆鐞冧綋棰滆壊
+    window.Viewer.scene.globe.baseColor = new Cesium.Color.fromCssColorString('#A9A9A9');
+    //娓呴櫎鎵�鏈夐粯璁ゅ浘灞� 
+    window.Viewer.imageryLayers.removeAll();
+    window.setLayer();
+
+
+    Viewer.scene.globe.depthTestAgainstTerrain = false; // 寮�鍚繁搴︽祴璇�
     Viewer.animation.container.style.visibility = "hidden";
     Viewer.timeline.container.style.visibility = "hidden";
     //=======================
     //澶ф皵灞�
     Viewer.scene.globe.showGroundAtmosphere = false;
-
-    // server.AddDemLayer("", 12316);
-
-    // server.AddTmsLayer(
-    //   "http://172.16.2.10:50001/sj_raster/v6/service/10003901/1"
-    // );
-
-    // var param = {
-    //     name: labelName,
-    //     id: earthCtrl.factory.createUUID(),
-    //     text: "鏂囧瓧宸ュ叿",
-    //     font: '50pt monospace',
-    //     outlineWidth: 2,
-    //     fillColor: SmartEarth.Cesium.Color.RED,
-    //     lon: 47.5087,
-    //     lat: 23.6963,
-    //     alt: 10
-    // };
-    // labelEntity = earthCtrl.factory.createLabel(param);
-
-    // server.AddTmsLayer('http://localhost:8080/abc');
-
-    // earthCtrl.camera.flyTo(47.5087, 23.6963, 300, 9.5, -45, 0.0, 5);
-
-    // //娣诲姞榧犳爣宸﹀嚮浜嬩欢
-    // this.addMouseLeftClickEvents();
-    // this.addMouseMouseMoveEvents();
+    sgworld._Viewer.scene.debugShowFramesPerSecond = false;
+    sgworld.Navigate.Stop(); //鍙栨秷椋炶鐘舵��
+    sgworld.Navigate.setPosition(-1093596.38, 5729026.12, 4136590.41);
+    this.addMouseLeftClickEvents();
+    this.addMouseLeftDownEvents();
   },
-  //榧犳爣宸﹂敭鐐瑰嚮浜嬩欢娣诲姞
-  addMouseLeftClickEvents() {
+  addMouseLeftDownEvents() {
     if (window.handleLeftClick) {
       window.handleLeftClick.removeInputAction(
         Cesium.ScreenSpaceEventType.LEFT_CLICK
       ); //绉婚櫎浜嬩欢
       window.handleLeftClick = null;
     }
+    const pickGlobeSlope = new SmartEarth.Cesium.PickGlobeSlope(earthCtrl.Viewer)
     window.handleLeftClick = new Cesium.ScreenSpaceEventHandler(
       window.Viewer.scene.canvas
     );
+    var that = this;
     window.handleLeftClick.setInputAction(function (event) {
-      let cartesian = window.Viewer.camera.pickEllipsoid(event.position);
-      if (cartesian) {
-        let cartographic = Cesium.Cartographic.fromCartesian(cartesian);
-        let lng = Cesium.Math.toDegrees(cartographic.longitude); // 缁忓害
-        let lat = Cesium.Math.toDegrees(cartographic.latitude); // 绾害
-        let alt = cartographic.height; // 楂樺害锛屾き鐞冮潰height姘歌繙绛変簬0
-        let coordinate = {
-          longitude: Number(lng.toFixed(6)),
-          latitude: Number(lat.toFixed(6)),
-          altitude: Number(alt.toFixed(2)),
-        };
+      const angle = pickGlobeSlope.pickSlope(event.position)
+      if (store.state.slopeQueyFlag) {
+        if (!store.state.showSlopeQuey) {
+          store.state.showSlopeQuey = true;
+        }
+        store.state.slopeQueyValue = angle.toFixed(6);
+
       }
+
     }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
   },
 
+  //榧犳爣宸﹂敭鐐瑰嚮浜嬩欢娣诲姞
+  addMouseLeftClickEvents() {
+    if (window.handleLeftDown) {
+      window.handleLeftDown.removeInputAction(
+        Cesium.ScreenSpaceEventType.LEFT_DOWN
+      ); //绉婚櫎浜嬩欢
+      window.handleLeftDown = null;
+    }
+    window.handleLeftDown = new Cesium.ScreenSpaceEventHandler(
+      window.Viewer.scene.canvas
+    );
+    var that = this;
+    window.handleLeftDown.setInputAction(function (event) {
+      let cartesian = window.Viewer.scene.pick(event.position);
+      if (Cesium.defined(cartesian)) {
+
+        if (cartesian.id.shpType && cartesian.id.shpType == 'temporaryLayer') {
+
+          that.setEditTemporaryLayer(cartesian.id._id)
+        }
+
+      }
+    }, Cesium.ScreenSpaceEventType.LEFT_DOWN);
+  },
+  setEditTemporaryLayer(res) {
+    // store.state.editTemporaryId = res;
+    // console.log(store.state.editTemporaryId)
+
+    if (store.state.editTemporaryId && store.state.editTemporaryId == res) {
+
+      store.state.setEditTemporaryShow = true;
+    }
+  },
   addMouseMouseMoveEvents() {
     if (window.handleMouseMove) {
       window.handleMouseMove.removeInputAction(
@@ -174,4 +206,4 @@
     console.log(moonPosition);
   },
 };
-export default InitMap;
+export default InitMap;
\ No newline at end of file

--
Gitblit v1.9.3