|
|
@@ -0,0 +1,78 @@
|
|
|
+<template>
|
|
|
+ <div
|
|
|
+ class="mousePoint"
|
|
|
+ v-show="$route.path !== '/overview' || !store.state.viewer_flag"
|
|
|
+ >
|
|
|
+ 坐标:{{ lonString }},{{ latString }}
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ handler: {},
|
|
|
+ lonString: 0,
|
|
|
+ latString: 0,
|
|
|
+ searchHeight: 0,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.init();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ init() {
|
|
|
+ this.handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
|
|
|
+ this.handler.setInputAction((e) => {
|
|
|
+ // 将屏幕空间的位置转换为笛卡尔世界坐标
|
|
|
+ let position = scene.pickPosition(e.endPosition);
|
|
|
+ // const cartesian = viewer.camera.pickEllipsoid(
|
|
|
+ // e.endPosition,
|
|
|
+ // viewer.scene.globe.ellipsoid
|
|
|
+ // );
|
|
|
+ if (position) {
|
|
|
+ // // 将笛卡尔坐标转换为笛卡尔地理坐标(经度和纬度)
|
|
|
+ const cartographic = Cesium.Cartographic.fromCartesian(position);
|
|
|
+ this.lonString = Cesium.Math.toDegrees(
|
|
|
+ cartographic.longitude
|
|
|
+ ).toFixed(6);
|
|
|
+ this.latString = Cesium.Math.toDegrees(cartographic.latitude).toFixed(
|
|
|
+ 6
|
|
|
+ );
|
|
|
+ this.searchHeight = cartographic.height.toFixed(2);
|
|
|
+ }
|
|
|
+ // // 显示经纬度
|
|
|
+ // console.log(
|
|
|
+ // `Longitude: ${lonString}, Latitude: ${latString}`
|
|
|
+ // );
|
|
|
+ // // 显示经纬度
|
|
|
+ }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ beforeDestroy() {
|
|
|
+ if (this.handler) {
|
|
|
+ this.handler.destroy();
|
|
|
+ this.handler = undefined;
|
|
|
+ }
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss">
|
|
|
+.mousePoint {
|
|
|
+ width: 250px;
|
|
|
+ background: url(/static/images/ghzc/内容框.png) no-repeat;
|
|
|
+ background-size: 100% 100%;
|
|
|
+ background-position: center;
|
|
|
+ padding: 0px 10px;
|
|
|
+ box-sizing: content-box;
|
|
|
+ text-align: left;
|
|
|
+ line-height: 40px;
|
|
|
+ overflow: hidden;
|
|
|
+ position: absolute;
|
|
|
+ right: 40px;
|
|
|
+ top: 95vh;
|
|
|
+}
|
|
|
+</style>
|