fuchengshen
2022-07-09 3a25c05b5ab837714f30469cdcb1e2a77d8d7f6c
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
131
132
133
134
135
136
137
138
139
140
<template>
  <mars-pannel :visible="true" right="10" top="10" width="280">
    <div class="f-mb">
      <a-space>
        <span class="mars-pannel-item-label">经度</span>
        <mars-input-number :step="0.000001" v-model:value="formState.lng" @change="onChangePosition" style="width: 100%">经度</mars-input-number>
      </a-space>
    </div>
    <div class="f-mb">
      <a-space>
        <span class="mars-pannel-item-label">纬度</span>
        <mars-input-number :step="0.000001" v-model:value="formState.lat" @change="onChangePosition" style="width: 100%">纬度</mars-input-number>
      </a-space>
    </div>
 
    <div class="f-mb">
      <a-space>
        <span class="mars-pannel-item-label">高度</span>
        <mars-input-number :step="0.1" v-model:value="formState.alt" @change="onChangePosition" style="width: 100%">高度</mars-input-number>
      </a-space>
    </div>
 
    <div class="f-mb">
      <a-space>
        <span class="mars-pannel-item-label">盒子X长度</span>
        <mars-slider @change="onChangeDimensionsX" v-model:value="formState.lengthX" :min="0" :max="100" :step="1.0" />
      </a-space>
    </div>
 
    <div class="f-mb">
      <a-space>
        <span class="mars-pannel-item-label">盒子Y长度</span>
        <mars-slider @change="onChangeDimensionsY" v-model:value="formState.lengthY" :min="0" :max="100" :step="1.0" />
      </a-space>
    </div>
 
    <div class="f-mb">
      <a-space>
        <span class="mars-pannel-item-label">盒子Z长度</span>
        <mars-slider @change="onChangeDimensionsZ" v-model:value="formState.lengthZ" :min="0" :max="100" :step="1.0" />
      </a-space>
    </div>
 
    <div class="f-mb">
      <a-space>
        <span class="mars-pannel-item-label">盒子</span>
        <a-checkbox @change="checkBox" v-model:checked="formState.isShowBox">是否显示</a-checkbox>
      </a-space>
    </div>
 
    <div class="f-tac">
      <a-space>
        <mars-button @click="drawExtent">绘制Box</mars-button>
        <mars-button @click="clear">清除</mars-button>
      </a-space>
    </div>
  </mars-pannel>
</template>
 
<script setup lang="ts">
import { reactive, onMounted } from "vue"
import type { UnwrapRef } from "vue"
import * as mapWork from "./map.js"
 
interface FormState {
  lng: number
  lat: number
  alt: number
  lengthX: number
  lengthY: number
  lengthZ: number
  isShowBox: boolean
}
 
const formState: UnwrapRef<FormState> = reactive({
  lng: 117.251283,
  lat: 31.843707,
  alt: 43.7,
  lengthX: 20,
  lengthY: 10,
  lengthZ: 15,
  isShowBox: true
})
 
onMounted(() => {
  const point = [formState.lng, formState.lat, formState.alt]
  mapWork.tilesetBoxClipDemo(point)
})
// 监听到事件
mapWork.eventTarget.on("hasDraw", (item: any) => {
  formState.lng = item.point.lng
  formState.lat = item.point.lat
  formState.alt = item.point.alt
})
 
// 清除
const clear = () => {
  mapWork.clear()
}
 
// 绘制
const drawExtent = () => {
  mapWork.drawExtent()
}
 
// 经度改变
const onChangePosition = () => {
  const point = [formState.lng, formState.lat, formState.alt]
 
  mapWork.onChangePosition(point)
}
 
// 是否显示盒子
const checkBox = () => {
  mapWork.showModelMatrix(formState.isShowBox)
}
 
// X长度改变
const onChangeDimensionsX = () => {
  mapWork.onChangeDimensionsX(formState.lengthX)
}
 
// Y长度改变
const onChangeDimensionsY = () => {
  mapWork.onChangeDimensionsY(formState.lengthY)
}
 
// Z长度改变
const onChangeDimensionsZ = () => {
  mapWork.onChangeDimensionsZ(formState.lengthZ)
}
</script>
<style scoped lang="less">
.infoView {
  width: 268px;
}
.ant-slider {
  width: 158px;
}
</style>