Browse Source

格网、分别绘制

zhiyuan-007 3 months ago
parent
commit
2c0fa867da
3 changed files with 130 additions and 13 deletions
  1. 20 10
      src/components/mapJK.vue
  2. 87 1
      src/config/basicTool.json
  3. 23 2
      src/units/map/addDrawEvent.js

+ 20 - 10
src/components/mapJK.vue

@@ -38,9 +38,6 @@ import GeometryMeshPrismEffect from "../units/map/GeometryMeshPrismEffect.js";
 import ReRenderingEvent from "../units/map/ReRenderingEvent.js";
 import PathPipeEvent from "../units/map/PathPipeEvent.js";
 import FlyGLTFEvent from "../units/map/FlyGLTFEvent.js";
-
-import GraphicsLayer from "@arcgis/core/layers/GraphicsLayer.js";
-import SketchViewModel from "@arcgis/core/widgets/Sketch/SketchViewModel.js";
 import AddDrawEvent from "../units/map/addDrawEvent.js";
 import SymbolPathPipeEvent from "../units/map/SymbolPathPipeEvent.js";
 import SymbolPointCubeEvent from "../units/map/SymbolPointCubeEvent.js";
@@ -197,6 +194,9 @@ export default {
           case "SymbolPointCube":
             symbolPointCube(params);
             break;
+          case "PathPlan":
+            pathPlan(params);
+            break;
         }
       }
       function setBackground(params){
@@ -829,9 +829,11 @@ export default {
         }
       }
 
+      //需要添加初始路径(手动绘制和自动绘制)结果
       function draw(params){
         let geometryType = params.type;
         let status = params.status;
+        let path = params.path;
         let hasZ = params.hasZ;
         let symbol = params.symbol;
         if(addDrawEvent){
@@ -841,13 +843,18 @@ export default {
         if(status == "hide"){
           return
         }
-        addDrawEvent = new AddDrawEvent({
-          view:m_view,
-          type:geometryType,
-          symbol,
-          hasZ
-        })
-        addDrawEvent.start();
+          addDrawEvent = new AddDrawEvent({
+            view:m_view,
+            type:geometryType,
+            symbol,
+            path:path,
+            hasZ
+          })
+        if(path){
+          addDrawEvent.update()
+        }else{
+          addDrawEvent.start();
+        }
       }
 
 
@@ -938,6 +945,9 @@ export default {
         })
         m_map.add(symbolPointCubeEvent.graphicsLayer);
       }
+      function pathPlan(params){
+
+      }
     })
   }
 }

+ 87 - 1
src/config/basicTool.json

@@ -58,7 +58,7 @@
             "title":"WhiteMold",
             "visible": true,
             "opacity": 1,
-            "url": "https://cimweb.zjw.sh.cegn.cn:2008/MapServiceProxy/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MzM5OTczMDYsImtleSI6IjA1MTk1NDE4Iiwic2VydmljZU5vIjoiRDkwMDMwMDA2MjAyMzA4MDEiLCJ1c2VybmFtZSI6InB0Z2wifQ.fWZuIUgQZhpSZPpK-y819W6nn89kK-Si_DPf0x1DhV8",
+            "url": "https://cimweb.zjw.sh.cegn.cn:2008/MapServiceProxy/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MzQxNzA3MzMsImtleSI6IjA1MTk1NDE4Iiwic2VydmljZU5vIjoiRDkwMDMwMDA2MjAyMzA4MDEiLCJ1c2VybmFtZSI6InB0Z2wifQ.6KDLNwwln28-DUVpxrDn48MmlSOIqp88QvbSsETkL98",
             "token": ""
           }
         }
@@ -655,6 +655,79 @@
             "type": "polyline",
             "hasZ": true,
             "status":"show",
+            "path": [
+              [
+                3499.5782683948523,
+                7252.273350408689,
+                0
+              ],
+              [
+                3499.364569722593,
+                7251.626996858693,
+                100
+              ],
+              [
+                3558.8660344507416,
+                7251.648514626977,
+                100
+              ],
+              [
+                3558.852005535551,
+                7290.14634859842,
+                100
+              ],
+              [
+                3568.767473443955,
+                7293.999751210939,
+                100
+              ],
+
+
+
+              [
+                4279.47656249917,
+                7294.283510610084,
+                100
+              ],
+              [
+                4282.768839396391,
+                7325.0832129770815,
+                100
+              ],
+              [
+                4286.069444710435,
+                7336.633997891262,
+                100
+              ],
+              [
+                4299.290211928166,
+                7340.489525285203,
+                100
+              ],
+
+
+              [
+                4309.205361465806,
+                7344.34362776725,
+                100
+              ],
+              [
+                4735.628798268906,
+                7344.538185844389,
+                100
+              ],
+              [
+                4735.579268035517,
+                7448.4823634558725,
+                100
+              ],
+              [
+                4734.06792183444,
+                7449.867157578444,
+                0
+              ]
+
+            ],
             "symbol": {
               "type": "line-3d",
               "symbolLayers": [{
@@ -841,6 +914,19 @@
             "token": ""
           }
         }
+      },
+      {
+        "code": "1-27",
+        "title": "航线规划",
+        "data": {
+          "ActionName": "pathPlan",
+          "Parameters": {
+            "status":"show",
+            "start": [4761.0851582425681,7580.2866520466015,22.27126711830264],
+            "end": [4452.8073415461002,6785.643477679952,19.200584820232107],
+            "token": ""
+          }
+        }
       }
     ]
   }

+ 23 - 2
src/units/map/addDrawEvent.js

@@ -1,6 +1,6 @@
 import GraphicsLayer from "@arcgis/core/layers/GraphicsLayer.js";
 import SketchViewModel from "@arcgis/core/widgets/Sketch/SketchViewModel.js";
-
+import Graphic from "@arcgis/core/Graphic.js";
 
 class AddDrawEvent {
     constructor(options) {
@@ -8,12 +8,14 @@ class AddDrawEvent {
         this.type = options.type;
         this.hasZ = options.hasZ || false;
         this.graphicLayer = null;
+        this.path = options.path || null;
+        this.graphic = null;
         this.sketchViewModel = null;
         this.createListenerEventHander = null;
         this.updateListenerEventHander = null;
         this.symbol = options.symbol;
     }
-    start(){
+    ready(){
         this.graphicLayer = new GraphicsLayer();
         this.view.map.add(this.graphicLayer);
         this.sketchViewModel = new SketchViewModel({
@@ -34,8 +36,27 @@ class AddDrawEvent {
                     break;
             }
         }
+        if(this.path){
+            const predefinedPath = {
+                type: "polyline",
+                paths: this.path, // 示例路径坐标
+                spatialReference: this.view.spatialReference,
+            };
+            this.graphic = new Graphic({
+                geometry: predefinedPath,
+                symbol: this.symbol,
+            });
+            this.graphicLayer.add(this.graphic);
+        }
+    }
+    start(){
+        this.ready();
         this.sketchViewModel.create(this.type);
     }
+    update(){
+        this.ready();
+        this.sketchViewModel.update([this.graphic]);
+    }
     createListenerEvent(callback){
         this.clearCreateListenerEvent()
         this.createListenerEventHander = this.sketchViewModel.on("create", (event) => {