月球大数据地理空间分析展示平台-【前端】-月球2期前端
surprise
2023-10-23 538d7313f98da3c304365f1c2b22c3e23d91db35
src/assets/js/Map/menuTool.js
@@ -19,6 +19,7 @@
    polygon: SmartEarth.Cesium.Color.fromCssColorString("#ffff0050"),
  },
  exportSquare: null,
  imageryProvider: null,
  topTools(res) {
    this.toolFlag = res.id;
    switch (res.id) {
@@ -103,6 +104,9 @@
    Viewer.animation.container.style.visibility = "visible";
    Viewer.timeline.container.style.visibility = "visible";
    earthCtrl.shadows = true;
    earthCtrl.terrainShadows = SmartEarth.Cesium.ShadowMode.ENABLED
    earthCtrl.shadowMap.size = 1024
  },
  setLocalPosition(res) {
    if (this.localPoint) {
@@ -155,32 +159,67 @@
    Viewer.scene.globe.material = window.material;
  },
  setImageLayerChange() {
    if (this.imageryProvider) {
      Viewer.imageryLayers.raiseToTop(this.imageryProvider);
    }
  },
  //等高线
  setcontour() {
    var globe = window.Viewer.scene.globe;
    if (window.material) {
      window.material = null;
      globe.material = null;
      store.state.slopeQueyFla = false
      store.state.slopeQueyFlag = false;
      store.state.showSlopeQuey = false;
      return;
    if (this.imageryProvider) {
      Viewer.imageryLayers.remove(this.imageryProvider);
      this.imageryProvider = null;
      return
    }
    var that = this;
    var imageryProvider = new Cesium.UrlTemplateImageryProvider({
      url: 'http://192.168.20.83:80/Moon/LFData/2d/tiles/contour_500/{mz}/{my}/{mx}.png',
      tilingScheme: new Cesium.GeographicTilingScheme(),
      customTags: {
        mz: function (imageryProvider, x, y, level) {
          return 'L' + that.zeroFill(level + 1, 2, 10); // 注意观测,层级加1了
        },
        mx: function (imageryProvider, x, y, level) {
          return 'C' + that.zeroFill(x, 8, 16);
        },
        my: function (imageryProvider, x, y, level) {
          return 'R' + that.zeroFill(y, 8, 16);
        }
      }
    });
    this.imageryProvider = Viewer.imageryLayers.addImageryProvider(imageryProvider);
    // var globe = window.Viewer.scene.globe;
    // if (window.material) {
    //   window.material = null;
    //   globe.material = null;
    //   store.state.slopeQueyFla = false
    //   store.state.slopeQueyFlag = false;
    //   store.state.showSlopeQuey = false;
    //   return;
    // }
    // var contourColor = new SmartEarth.Cesium.Color(
    //   117 / 255,
    //   71 / 255,
    //   18 / 255,
    //   255 / 255
    // );
    // var contourUniforms = {};
    // window.material = Cesium.Material.fromType("ElevationContour");
    // contourUniforms = material.uniforms;
    // contourUniforms.width = 1.0;
    // contourUniforms.spacing = 100.0;
    // contourUniforms.color = contourColor;
    // globe.material = window.material;
  },
  zeroFill(num, len, radix) {
    var str = num.toString(radix || 10)
    while (str.length < len) {
      str = '0' + str
    }
    var contourColor = new SmartEarth.Cesium.Color(
      117 / 255,
      71 / 255,
      18 / 255,
      255 / 255
    );
    var contourUniforms = {};
    window.material = Cesium.Material.fromType("ElevationContour");
    contourUniforms = material.uniforms;
    contourUniforms.width = 1.0;
    contourUniforms.spacing = 100.0;
    contourUniforms.color = contourColor;
    globe.material = window.material;
    return str;
  },
  //线查询
  spatialLineQuery() {
@@ -634,6 +673,10 @@
      store.state.slopeQueyFlag = false;
      store.state.showSlopeQuey = false;
    }
    if (this.imageryProvider) {
      Viewer.imageryLayers.remove(this.imageryProvider)
      this.imageryProvider = null;
    }
    if (window.DoubleScreen) {
      window.DoubleScreen && window.DoubleScreen.destroy();
      window.DoubleScreen = null;