月球大数据地理空间分析展示平台-【前端】-月球2期前端
WX
2023-08-10 374c78e8727a50a3153c0ad7a263efca6fc68c98
经纬度格网
已修改4个文件
243 ■■■■■ 文件已修改
src/assets/js/Map/index.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/mouseMove.vue 234 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/validCode.vue 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/menus.vue 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/assets/js/Map/index.js
@@ -37,7 +37,7 @@
    sgworld.Creator.SimpleGraphic.edit(true, { editProp: true });
    //=======================
    window.Viewer.imageryLayers.removeAll();
    // window.Viewer.imageryLayers.removeAll();
    Viewer.animation.container.style.visibility = "hidden";
    Viewer.timeline.container.style.visibility = "hidden";
    //=======================
src/components/mouseMove.vue
@@ -1,16 +1,17 @@
<template>
  <div
    class="mouseBox"
    @setMouseMove="setMouseMove"
  >
    <div class="earthImage"></div>
    <div class="earthLable">经度 : </div>
    <div class="earthLable"> {{ longitude }}</div>
    <div class="earthLable">纬度 : </div>
    <div class="earthLable"> {{ latitude }}</div>
    <div class="earthLable">分辨率 : </div>
    <div class="earthLable"> {{ rate }}</div>
    <div class="earthLable"> m/px</div>
  <div class="mouseBox" @setMouseMove="setMouseMove">
    <div
      class="earthImage"
      :class="{ active: gridIsshow }"
      @click="gridSwitch"
    ></div>
    <div class="earthLable">经度 :</div>
    <div class="earthLable">{{ longitude }}</div>
    <div class="earthLable">纬度 :</div>
    <div class="earthLable">{{ latitude }}</div>
    <div class="earthLable">分辨率 :</div>
    <div class="earthLable">{{ rate }}</div>
    <div class="earthLable">m/px</div>
  </div>
</template>
@@ -26,6 +27,17 @@
const longitude = ref("0.00");
const latitude = ref("0.00");
const rate = ref("0.00");
let entitiesObj = reactive({
  lonLine: [],
  latLine: [],
});
let gridIsshow = ref(false);
let levelArray = [
  0, 40000000, 20000000, 10000000, 5000000, 2000000, 1000000, 500000, 250000,
  200000, 100000, 50000, 17000, 9000, 5000, 2000, 1000, 500, 200, 100, 50, 25,
  10, 0,
];
let heightlevel = "";
const setMouseMove = (res) => {
  let handlerPoint = new SmartEarth.Cesium.ScreenSpaceEventHandler(
    window.Viewer.scene.canvas
@@ -78,6 +90,195 @@
    }
  }, SmartEarth.Cesium.ScreenSpaceEventType.MOUSE_MOVE);
};
const gridSwitch = () => {
  gridIsshow.value = !gridIsshow.value;
  if (gridIsshow.value) {
    grid(10);
    // getHeight();
    // createPrimitives();
  } else {
    gridDel();
  }
};
const getHeight = () => {
  let removeListener = Viewer.camera.changed.addEventListener(() => {
    // 当前高度
    let height = Viewer.camera.positionCartographic.height;
    heightlevel = getLevel(height);
    console.log(heightlevel);
    if (heightlevel == 6) {
      gridDel();
      grid(5);
    }
    // if (heightlevel <= 6) {
    //   gridDel();
    //   grid(10);
    // }
    if (heightlevel == 8) {
      gridDel();
      grid(1);
    }
  });
};
const getLevel = (height) => {
  for (var i = 1, len = levelArray.length; i < len - 1; i++) {
    if (height >= (levelArray[i] + levelArray[i + 1]) / 2) {
      return i;
    }
  }
  return levelArray.length - 1;
};
const createPrimitives = (degree) => {
  // let ps = [];
  // for (let longitude = -180; longitude <= 180; longitude += 10) {
  //   ps.push(
  //     Cesium.Cartesian3.fromDegreesArray([
  //       longitude,
  //       -90,
  //       longitude,
  //       0,
  //       longitude,
  //       90,
  //     ])
  //   );
  // }
  // console.log(ps);
  // let polylineGeometry = new Cesium.PolylineGeometry({
  //   positions: ps,
  //   width: 5,
  //   id: "polylineGeometry",
  // });
  // Viewer.scene.primitives.add(
  //   new Cesium.Primitive({
  //     geometryInstances: new Cesium.GeometryInstance({
  //       geometry: polylineGeometry,
  //     }),
  //     // vertexFormat: Cesium.PolylineColorAppearance.VERTEX_FORMAT,
  //     appearance: new Cesium.EllipsoidSurfaceAppearance({
  //       material: Cesium.Material.fromType("Stripe"),
  //     }),
  //   })
  // );
  var GridImagery = new Cesium.GridImageryProvider();
  var imageryLayers = Viewer.imageryLayers;
  var GridImageryLayer = imageryLayers.addImageryProvider(GridImagery); // 添加网格图层
  imageryLayers.raiseToTop(GridImageryLayer); // 将网格图层置顶
};
const grid = (degree) => {
  const entities = Viewer.entities;
  for (let longitude = -180; longitude <= 180; longitude += degree) {
    console.log(
      Cesium.Cartesian3.fromDegreesArray([
        longitude,
        -90,
        longitude,
        0,
        longitude,
        90,
      ])
    );
    let text = "";
    if (longitude === 0) {
      text = "0";
    }
    text += longitude === 0 ? "" : "" + longitude + "°";
    if (longitude === -180) {
      text = "";
    }
    let obj = entities.add({
      position: Cesium.Cartesian3.fromDegrees(longitude, 0),
      polyline: {
        positions: Cesium.Cartesian3.fromDegreesArray([
          longitude,
          -90,
          longitude,
          0,
          longitude,
          90,
        ]),
        width: 4.0,
        material: new Cesium.Color.fromCssColorString("#c8b284"),
        clampToGround: true, //开启贴地
      },
      label: {
        text: text,
        verticalOrigin: Cesium.VerticalOrigin.LEFT,
        font: "16px sans-serif",
        fillColor: new Cesium.Color.fromCssColorString("#000"),
        outlineWidth: "6px sans-serif", // 字体外圈线宽度(同样也有颜色可设置)
        outlineColor: new Cesium.Color.fromCssColorString("#000"),
        // 这里设置了就不会被遮盖了,设为负值则在更上层
        eyeOffset: new Cesium.Cartesian3(0, 0, -10000),
      },
    });
    entitiesObj.lonLine.push(obj);
  }
  let langS = [];
  for (let longitude = -180; longitude <= 180; longitude += 5) {
    langS.push(longitude);
  }
  //每隔10读绘制一条纬度线和纬度标注,自己控制间隔
  for (let lat = -80; lat <= 80; lat += degree) {
    let text = "";
    text += "" + lat + "°";
    if (lat === 0) {
      text = "";
    }
    // console.log(lat, "---lat");
    let obj = entities.add({
      position: Cesium.Cartesian3.fromDegrees(0, lat),
      polyline: {
        positions: Cesium.Cartesian3.fromDegreesArray(
          langS
            .map((long) => {
              return [long, lat].join(",");
            })
            .join(",")
            .split(",")
            .map((item) => Number(item))
        ),
        width: 4.0,
        material: new Cesium.Color.fromCssColorString("#c8b284"),
        clampToGround: true, //开启贴地
      },
      label: {
        text: text,
        font: "18px sans-serif",
        fillColor: new Cesium.Color.fromCssColorString("#000"),
        outlineWidth: 6, // 字体外圈线宽度(同样也有颜色可设置)
        outlineColor: new Cesium.Color.fromCssColorString("#000"),
        verticalOrigin: Cesium.VerticalOrigin.BOTTOM, // 垂直位置
        pixelOffset: new Cesium.Cartesian2(0, 15), // 中心位置
        // 这里设置了就不会被遮盖了,设为负值则在更上层
        eyeOffset: new Cesium.Cartesian3(0, 0, -10000),
      },
    });
    entitiesObj.latLine.push(obj);
  }
  console.log(entitiesObj);
  // 抗锯齿
  if (Cesium.FeatureDetection.supportsImageRenderingPixelated()) {
    //判断是否支持图像渲染像素化处理
    Viewer.resolutionScale = window.devicePixelRatio;
  }
  //开启抗锯齿
  Viewer.scene.fxaa = true;
  Viewer.scene.postProcessStages.fxaa.enabled = true;
};
const gridDel = () => {
  if (entitiesObj.lonLine.length > 0) {
    entitiesObj.lonLine.forEach((e) => {
      Viewer.entities.remove(e);
    });
    entitiesObj.lonLine = [];
  }
  if (entitiesObj.latLine.length > 0) {
    entitiesObj.latLine.forEach((e) => {
      Viewer.entities.remove(e);
    });
    entitiesObj.latLine = [];
  }
};
onMounted(() => {
  window.setMouseMove = setMouseMove;
  //   const handleMouseMove =
@@ -103,6 +304,7 @@
    background: url("../assets/img/形状 9.png") no-repeat;
    background-size: 100% 100%;
    margin-left: 10px;
    cursor: pointer;
  }
  .earthLable {
    font-size: 16px;
@@ -112,5 +314,11 @@
    line-height: 5px;
    margin-left: 10px;
  }
  .active {
    background-color: #171e2e;
    border: 1px solid;
    border-image: linear-gradient(47deg, #397bc9, #77a5cd, #397bc9) 1 1;
    box-shadow: 0px 0px 6px 0px #080c13, 0px 7px 8px 0px rgba(38, 47, 71, 0.68);
  }
}
</style>
</style>
src/components/validCode.vue
@@ -5,7 +5,7 @@
      :width="state.width"
      :height="state.height"
      @click="handleDraw"
      style="border-radius: 5px;"
      style="border-radius: 5px"
    ></canvas>
  </div>
</template>
@@ -15,7 +15,7 @@
import { useStore } from "vuex"; // 引入useStore 方法
import emitter from "@/utils/bus";
const store = useStore(); // 该方法用于返回store 实例
const verify = ref(null);
const verify = ref();
const state = reactive({
  pool: "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", // 字符串
  width: 120,
@@ -133,4 +133,4 @@
  justify-content: center;
  border-radius: 5px;
}
</style>
</style>
src/views/menus.vue
@@ -136,7 +136,6 @@
      console.log(fullScreen.value);
    }
  }
  console.log(isFullScreen());
});
// 判断是否全屏
function isFullScreen() {