From 0b7865733542931c7c3fcf74febd30fe145af957 Mon Sep 17 00:00:00 2001
From: suerprisePlus <15810472099@163.com>
Date: 星期三, 12 六月 2024 09:38:18 +0800
Subject: [PATCH] 页面修改

---
 src/assets/js/map/mapServer.js |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/assets/js/map/mapServer.js b/src/assets/js/map/mapServer.js
index fd954da..ab6694a 100644
--- a/src/assets/js/map/mapServer.js
+++ b/src/assets/js/map/mapServer.js
@@ -5,8 +5,9 @@
   sourceType: null,
   init() {},
   addServer(res) {
+    this.remoServer(res);
     this.sourceType = res.sourceType;
-    console.log(this.sourceType);
+
     switch (this.sourceType) {
       case "arcgis":
         this.addArcgisServer(res);
@@ -19,17 +20,26 @@
         break;
     }
   },
+  remoServer(res) {
+    for (var i in this.listData) {
+      const obj = this.listData[i];
+      if (obj.type == res.sourceType) {
+        obj.layer.removeFromMap();
+        this.listData.splice(i, 1);
+      }
+    }
+  },
   addTmsLayer(res) {
-    console.log(res.url);
     var layer = earthCtrl.factory.createImageryLayer({
-        sourceType: "tms",
-        url: "http://test.smartearth.cn:9037/gisserver/tmsserver/SubicBayArea",
+      sourceType: "tms",
+      // url: "http://test.smartearth.cn:9037/gisserver/tmsserver/SubicBayArea"
+      url: res.url
     });
     this.listData.push({
       layer: layer,
       type: this.sourceType
     });
-    mapConfig.flyToImageryLayer(layer)
+    mapConfig.flyToImageryLayer(layer);
   },
   addArcgisServer(res) {
     const layer = earthCtrl.factory.createImageryLayer({
@@ -40,7 +50,6 @@
       layer: layer,
       type: this.sourceType
     });
-    
   },
   addGeoServer(res) {
     const layer = earthCtrl.factory.createWfsLayer("polygon", {

--
Gitblit v1.9.3