lixuliang
2024-04-18 b5c4921d0828500379502a916a2ccf2d9d4acc96
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/* eslint-disable no-undef */
 <template>
  <Popup
    ref="pop"
    :title="form.title"
    width="410px"
    maxHeight="430px"
    left="calc(100% - 420px)"
    @close="clearAll"
  >
    <div class="posjump">
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="经度:" prop="longitude">
          <el-input v-model="form.longitude"></el-input>
        </el-form-item>
        <el-form-item label="纬度:" prop="latitude">
          <el-input v-model="form.latitude"></el-input>
        </el-form-item>
        <el-form-item label="高度:" prop="viewHeight">
          <el-input v-model="form.viewHeight"></el-input>
        </el-form-item>
        <el-form-item label="航向角:" prop="heading">
          <el-input v-model="form.heading"></el-input>
        </el-form-item>
        <el-form-item label="俯仰角:" prop="pitch">
          <el-input v-model="form.pitch"></el-input>
        </el-form-item>
        <!-- <el-form-item label="翻滚角:" prop="roll">
          <el-input v-model="form.roll"></el-input>
        </el-form-item> -->
        <el-form-item>
          <el-button @click="flyToPos" type="primary" class="posBtn">
            飞到
          </el-button>
          <el-button @click="jumpToPos" type="primary" class="posBtn">
            跳转
          </el-button>
        </el-form-item>
      </el-form>
    </div>
  </Popup>
</template>
<script>
import Popup from "@tools/Popup.vue";
export default {
  name: "Location",
  components: {
    Popup,
  },
  data() {
    return {
      dialogVisible: false,
      loading: false,
      form: {
        title: "飞行定位",
        longitude: 0,
        latitude: 0,
        viewHeight: 0,
        heading: 0,
        pitch: 0,
 
      },
    };
  },
  mounted() {},
  methods: {
    clearAll() {},
    flyToPos() {
      window.Viewer.camera.flyTo({
        destination: Cesium.Cartesian3.fromDegrees(
          this.form.longitude,
          this.form.latitude,
          this.form.viewHeight
        ),
        orientation: {
          heading: (this.form.heading * 3.1415926) / 180,
          pitch: (this.form.pitch * 3.1415926) / 180,
        },
      });
    },
    jumpToPos() {
      window.sgworld.Navigate.jumpTo({
        destination: Cesium.Cartesian3.fromDegrees(
          this.form.longitude,
          this.form.latitude,
          this.form.viewHeight
        ),
        orientation: {
          heading: (this.form.heading * 3.1415926) / 180,
          pitch: (this.form.pitch * 3.1415926) / 180,
        },
      });
    },
    // 打开弹窗
    open() {
      let cameraPosition = sgworld.Navigate.getDegrees();
      if (cameraPosition) {
        this.form.viewHeight = cameraPosition.height.toFixed(2);
        this.form.longitude = cameraPosition.lon.toFixed(6);
        this.form.latitude = cameraPosition.lat.toFixed(6);
        this.form.heading = Cesium.Math.toDegrees(Viewer.camera.heading).toFixed(1);
        this.form.pitch = Cesium.Math.toDegrees(Viewer.camera.pitch).toFixed(1);
      }
      this.$refs.pop.open();
    },
  },
};
</script>
<style lang="less">
.posjump {
  margin-top: 20px;
  .el-form-item__label {
    color: white;
  }
  .jumpBtn {
    position: relative;
    left: 40%;
  }
  .el-radio {
    width: 100px;
    margin-right: 0px;
  }
  .el-input {
    width: 300px;
  }
  /deep/ .el-input__inner {
    width: 95%;
  }
}
</style>