suerprisePlus
2024-06-12 0b7865733542931c7c3fcf74febd30fe145af957
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import mapConfig from "./mapConfig";
 
const mapServer = {
  listData: [],
  sourceType: null,
  init() {},
  addServer(res) {
    this.remoServer(res);
    this.sourceType = res.sourceType;
 
    switch (this.sourceType) {
      case "arcgis":
        this.addArcgisServer(res);
        break;
      case "geoserver":
        this.addGeoServer(res);
        break;
      case "tms":
        this.addTmsLayer(res);
        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) {
    var layer = earthCtrl.factory.createImageryLayer({
      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);
  },
  addArcgisServer(res) {
    const layer = earthCtrl.factory.createImageryLayer({
      sourceType: "arcgis",
      url: res.url
    });
    this.listData.push({
      layer: layer,
      type: this.sourceType
    });
  },
  addGeoServer(res) {
    const layer = earthCtrl.factory.createWfsLayer("polygon", {
      urls: res.url,
      layer: res.layerF,
      color: "#de3",
      extrudedHeight: 30 // 拉伸高度,无拉伸高度则为贴地面
    });
    this.listData.push({
      layer: layer,
      type: this.sourceType
    });
  }
};
export default mapServer;