From 9398f14feea7ad8b7d00ce7d2bb2e5362cec59d3 Mon Sep 17 00:00:00 2001
From: surprise <15810472099@163.com>
Date: 星期二, 09 一月 2024 15:20:15 +0800
Subject: [PATCH] 代码提交

---
 src/assets/js/Layer/mapGeo.js |   35 +++++++++++++++++++++++++++++++----
 1 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/src/assets/js/Layer/mapGeo.js b/src/assets/js/Layer/mapGeo.js
index 83da005..59a2856 100644
--- a/src/assets/js/Layer/mapGeo.js
+++ b/src/assets/js/Layer/mapGeo.js
@@ -1,7 +1,12 @@
 var source = []
 const mapGeo = {
     source1: null,
+    type: null,
     init(res) {
+        if (this.type && this.type === res) {
+            return this.type = null
+        }
+        this.type = res;
         switch (res.type) {
             case "WangGe":
                 this.addWangGeGeoJson(res);
@@ -17,11 +22,33 @@
                 break;
             case "zhaiHai":
                 this.addzhaiHaiGeoJson(res)
-
+                break;
+            case "ZhongPo":
+                this.addZhongPoGeoJson(res)
                 break;
         }
     },
+
+    addZhongPoGeoJson(res) {
+        var url = layerData.config.Model_URL + res.urls;
+        var data = Cesium.GeoJsonDataSource.load(url, //瑕佸姞杞界殑 url銆丟eoJSON 瀵硅薄鎴� TopoJSON 瀵硅薄銆�
+            {
+                stroke: Cesium.Color.ORANGE, //鎶樼嚎鍜屽杈瑰舰杞粨鐨勯粯璁ら鑹层��
+                fill: Cesium.Color.WHITE.withAlpha(0.2), //澶氳竟褰㈠唴閮ㄧ殑榛樿棰滆壊銆�
+                strokeWidth: 3, //鎶樼嚎鍜屽杈瑰舰杞粨鐨勯粯璁ゅ搴︺��
+            }
+        )
+        data.then((dataSource) => {
+            dataSource.name = res.type
+            Viewer.dataSources.add(
+                dataSource
+            );
+        })
+    },
     delGeoSource(res) {
+        if (this.type && this.type == res) {
+            this.type = null
+        }
         if (res.type == "zhaiHai") {
             Viewer.dataSources.remove(Viewer.dataSources.getByName("zhaiHai2")[0])
             Viewer.dataSources.remove(Viewer.dataSources.getByName("zhaiHai1")[0])
@@ -129,11 +156,11 @@
         })
     },
     addZhuangHaoGeoJson(res) {
-        
+
         var url = layerData.config.Model_URL + res.urls;
         var img = layerData.config.Model_URL + '/Data/img/img1.png';
-       Cesium.GeoJsonDataSource.load(url).then((dataSource) => {
-      
+        Cesium.GeoJsonDataSource.load(url).then((dataSource) => {
+
             dataSource.name = res.type
             Viewer.dataSources.add(
                 dataSource

--
Gitblit v1.9.3