suerprisePlus
2024-06-25 c93d4b3af5739f786cfdf20b16b28ec60403f709
src/assets/js/map/modelLayer.js
@@ -1,7 +1,10 @@
import {
  getPublickey,
  getSecurityLogin,
  getListCanview
  getListCanview,
  getmapConfig,
  getQueryEentity,
  getSettingPublickey
} from "../../../api/modelBase.js";
import JSEncrypt from "jsencrypt";
import store from "../../../store/index.js";
@@ -14,9 +17,16 @@
  modelBase: null,
  dbid: null,
  geom: null,
  // 获取Publickey
  layers: null,
  publickey: null,
  init() {
    this.modelBase = config.modelBase;
    this.getSettingPublicKey();
    const token = getToken();
    console.log("token", token);
    if (token) {
      this.getModelLayerList();
    } else {
    getPublickey().then((response) => {
      const password = this.modelBase.password;
      const userId = this.modelBase.userId;
@@ -30,19 +40,20 @@
      };
      this.setLoginsubmit(submit);
    });
    }
  },
  getSettingPublicKey() {
    getSettingPublickey().then((response) => {
      this.publickey = response.data;
    });
  },
  // 获取Token
  setLoginsubmit(res) {
    // const token = getToken();
    // if (token) {
    getSecurityLogin(res).then((response) => {
      const val = response.data.token;
      setToken(val);
      this.getModelLayerList();
    });
    // } else {
    //   this.getModelLayerList( );
    // }
  },
  // 获取列表
  getModelLayerList() {
@@ -56,19 +67,40 @@
      });
      if (obj.length > 0) {
        this.dbid = obj[0].dbid;
        this.getmapConfig();
      }
    });
    this.setLayerQuery();
  },
  getmapConfig() {
    getmapConfig({
      dbid: this.dbid,
      token: getToken()
    }).then((response) => {
      if (response.code != 200) return;
      const layers = response.data.layers;
      this.layers = layers;
      for (var i in layers) {
        if (layers[i].name == "建筑") {
          const url = layers[i].lod_url["3d"][""];
          mapServer.addServer({
            sourceType: "Tileset",
            url: url,
            id: layers[i].id
          });
        }
      }
    });
  },
  setLayerQuery() {
    const token = getToken();
    this.geom = mapConfig.setPointToCrical(120.27, 14.79, null);
    const obj = {
      type: "FeatureCollection",
      totalFeatures: 1086,
      features: [this.geom]
    };
    // const obj = {
    //   type: "FeatureCollection",
    //   totalFeatures: 1086,
    //   features: [this.geom]
    // };
    // earthCtrl.factory.createFeatureLayer({
    //   sourceType: "geojson",
    //   url: obj,
@@ -168,7 +200,7 @@
    //
    a.push([
      // "${id} == '1_b092c0c26de646b984801e29fba37f82'",
      '${id} == 1_b092c0c26de646b984801e29fba37f82',
      "${id} == 1_b092c0c26de646b984801e29fba37f82",
       'color("purple", 0.5)'
    ]);
    a.push(["true", "color('#E8F1F2', 0.5)"]);