From 12a2d994bace6430a49e390b2ed3df9e00af6168 Mon Sep 17 00:00:00 2001
From: suerprisePlus <15810472099@163.com>
Date: 星期四, 27 六月 2024 17:05:37 +0800
Subject: [PATCH] 方案2

---
 src/views/chartView/index.vue     |    3 -
 src/assets/js/map/mapJsonLayer.js |   75 ++++++++++++++++++++++++++++++++-----
 2 files changed, 65 insertions(+), 13 deletions(-)

diff --git a/src/assets/js/map/mapJsonLayer.js b/src/assets/js/map/mapJsonLayer.js
index 0105eff..927aeac 100644
--- a/src/assets/js/map/mapJsonLayer.js
+++ b/src/assets/js/map/mapJsonLayer.js
@@ -20,7 +20,7 @@
   targetList: [],
   linePath: null,
   richTextPoint1: null,
-  wfsLayer:null,
+  wfsLayer: null,
   init(url) {
     this.url = url;
     this.getJsonLayer();
@@ -233,7 +233,7 @@
   },
   setTitleSetRest() {
     this.targetList = [];
-    if(this.wfsLayer){
+    if (this.wfsLayer) {
       // this.wfsLayer.removeFromMap();
       this.wfsLayer.destroy();
     }
@@ -289,7 +289,7 @@
     if (objItem.length <= 0) return;
     var tileset = objItem[0].layer;
     const list = this.targetList;
- 
+
     tileset.style = new Cesium.Cesium3DTileStyle({
       color: {
         evaluateColor: (feature) => {
@@ -308,13 +308,66 @@
       }
     });
   },
-  setAddWfsLayer(){
-    this.wfsLayer = earthCtrl.factory.createWfsLayer('polygon', {
-      urls: 'https://cim.smartearth.cn/SEserver/wfsserver/SubicBayWeapon_wfs',
-      layer: 'weapons',
-      outlineColor:'#ff0000',
-      alpha:0,
-    })
+  setAddWfsLayer() {
+    this.wfsLayer = earthCtrl.factory.createWfsLayer("polygon", {
+      urls: "https://cim.smartearth.cn/SEserver/wfsserver/SubicBayWeapon_wfs",
+      layer: "weapons",
+      outlineColor: "#ff0000",
+      alpha: 0
+    });
+  },
+  setAddWfsJson() {
+    const url = this.getQueryUrl("SubicBayWeapon_wfs", "weapons");
+
+    Cesium.GeoJsonDataSource.load(url, {
+      fill: Cesium.Color.fromCssColorString("#FFFFFF00"),
+      stroke: Cesium.Color.fromCssColorString("#FFFFFF00"), //澶氳竟褰㈡垨绾跨殑棰滆壊
+
+      strokeWidth: 0 //澶氳竟褰㈡垨绾� 瀹藉害
+    }).then((dataSource) => {
+      const entities = dataSource.entities.values;
+      entities.map((item) => {
+        item.polygon._material.color =
+          Cesium.Color.fromCssColorString("#FFFFFF00");
+
+        item.polygon.heightReference =
+          Cesium.HeightReference.RELATIVE_TO_GROUND; // 璐村湴
+        item.polygon.height = 0; // 璺濆湴楂樺害0绫�
+        var polyPositions = item.polygon.hierarchy.getValue().positions;
+        var polyCenter = Cesium.BoundingSphere.fromPoints(polyPositions).center; //涓績鐐�
+        polyCenter = Cesium.Ellipsoid.WGS84.scaleToGeodeticSurface(polyCenter);
+        item.position = polyCenter;
+        let positions = item.polygon.hierarchy._value.positions;
+        // 璁剧疆闈㈣疆寤�
+        item.polyline = new Cesium.PolylineGraphics({
+          positions: positions,
+          clampToGround: true, // 璐村湴
+          width: 5,
+          material: Cesium.Color.fromCssColorString("#FF0000")
+        });
+       console.log(item._name);
+       const label_name = item.name ?item.name :"";
+        item.label = {
+          text: label_name,
+          font: "500 16x sans-serif",
+          style: Cesium.LabelStyle.FILL_AND_OUTLINE, // 瀛椾綋鏍峰紡
+          fillColor: new Cesium.Color.fromCssColorString("#FFFFFF"), 
+          outlineWidth: 1,  // 瀛椾綋澶栧湀绾垮搴︼紙鍚屾牱涔熸湁棰滆壊鍙缃級
+          outlineColor: new Cesium.Color.fromCssColorString("#FFFFFF"), 
+          verticalOrigin: Cesium.VerticalOrigin.BOTTOM, // 鍨傜洿浣嶇疆
+          pixelOffset: new Cesium.Cartesian2(0, 0), // 涓績浣嶇疆
+          disableDepthTestDistance: Number.POSITIVE_INFINITY,
+          distanceDisplayCondition: new Cesium.DistanceDisplayCondition(
+            500.0,
+            3000.0
+          ),
+          // showBackground:true,
+          // backgroundColor: new Cesium.Color(26 / 255, 196 / 255, 228 / 255, 1.0) //鑳屾櫙椤旇壊
+        };
+      });
+
+      Viewer.dataSources.add(dataSource);
+    });
   },
   getTileSet() {
     var objItem = mapServer.listData.filter((item) => {
@@ -463,7 +516,7 @@
       width: 3, //绾垮锛堝彲閫夛級
       color: "#00ffff", //绾块鑹诧紙鍙�夛級,
       LightSpot: true, //鏄惁浣跨敤鍏夌偣鏁堟灉锛堝彲閫夛級
-      LightSpotColor: "#ffffff" ,//鍏夌偣棰滆壊锛堝彲閫夛級
+      LightSpotColor: "#ffffff", //鍏夌偣棰滆壊锛堝彲閫夛級
       height: 100
     };
     this.linePath = earthCtrl.factory.createTrailLinePath(
diff --git a/src/views/chartView/index.vue b/src/views/chartView/index.vue
index 2dc0934..f757b69 100644
--- a/src/views/chartView/index.vue
+++ b/src/views/chartView/index.vue
@@ -270,7 +270,6 @@
       mapInfo.setEntityQueryInput();
       switch (res) {
         case "scanWeapon":
-
           mapInfo.setFlyTo({
             "longitude": 120.26907736668211,
             "latitude": 14.791708841800627,
@@ -279,7 +278,7 @@
           var obj = this.getQueryGroupBy("姝﹀櫒", "weaponname")
           this.getQueryEentityGroupBy(obj, "weaponname")
           layerJson.setAddWfsLayer();
-
+          // layerJson.setAddWfsJson();
           break;
         case "weaponParameters":
           var obj = this.getQueryGroupBy("姝﹀櫒", "description")

--
Gitblit v1.9.3