suerprisePlus
2024-06-25 c93d4b3af5739f786cfdf20b16b28ec60403f709
src/assets/js/map/mapServer.js
@@ -1,12 +1,14 @@
import mapConfig from "./mapConfig";
var tileset;
const mapServer = {
  listData: [],
  sourceType: null,
  tileContent: null,
  init() {},
  addServer(res) {
    // this.remoServer(res);
    this.sourceType = res.sourceType;
    console.log(this.sourceType);
    switch (this.sourceType) {
      case "arcgis":
        this.addArcgisServer(res);
@@ -17,19 +19,72 @@
      case "tms":
        this.addTmsLayer(res);
        break;
      case "wfs":
        this.addWfsLayer(res);
        break;
      case "Tileset":
        this.addTileSetLayer(res);
        break;
    }
  },
  addTmsLayer(res) {
    console.log(res.url);
    var layer = earthCtrl.factory.createImageryLayer({
        sourceType: "tms",
        url: "http://test.smartearth.cn:9037/gisserver/tmsserver/SubicBayArea",
  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);
      }
    }
  },
  addTileSetLayer(res) {
    //   const model =  earthCtrl.factory.create3DTilesets({
    //     url: res.url
    // });
    // var model = Viewer.scene.primitives.add(
    //   new Cesium.Cesium3DTileset({
    //     // url: res.url
    //     url:'https://cim.smartearth.cn/SEServer/c3dserver/WhiteBox/tileset.json'
    //   })
    // );
    const tileset = new Cesium.Cesium3DTileset({
      url: res.url
    });
    earthCtrl.primitives.add(tileset);
    this.listData.push({
      layer: tileset,
      type: this.sourceType,
      layerId: res.id
    });
  },
  traverseVisibleTiles() {
    tileset.readyPromise.then((tileset) => {
      tileset.tileVisibility.forEachTile(function (tile) {});
    });
  },
  addWfsLayer(res) {
    const layer = earthCtrl.factory.createWfsLayer("polygon", {
      urls: res.url,
      layer: res.layer,
      outlineColor: res.outlineColor,
      alpha: res.alpha
    });
    this.listData.push({
      layer: layer,
      type: this.sourceType
    });
    mapConfig.flyToImageryLayer(layer)
  },
  addTmsLayer(res) {
    const layer = earthCtrl.factory.createImageryLayer({
      sourceType: "tms",
      url: res.url
    });
    this.listData.push({
      layer: layer,
      type: this.sourceType
    });
  },
  addArcgisServer(res) {
    const layer = earthCtrl.factory.createImageryLayer({
@@ -40,7 +95,6 @@
      layer: layer,
      type: this.sourceType
    });
  },
  addGeoServer(res) {
    const layer = earthCtrl.factory.createWfsLayer("polygon", {