measure.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <script setup>
  2. /**
  3. * element-plus组件
  4. */
  5. import {
  6. ElMessage
  7. } from 'element-plus';
  8. import {
  9. inject
  10. } from "vue";
  11. const getMapInstance = inject("getMapInstance");
  12. jt3d = getMapInstance();
  13. </script>
  14. <template>
  15. <div class="jt-measure">
  16. <el-row :gutter="20" style="margin-left: 0rem; margin-right: 0rem; ">
  17. <el-col :span="8" v-for="(item,index) in measure" @click="handleMeasure(item.type,index)">
  18. <el-avatar shape="circle" :size="70" :class="currentIndex===index?'selectStyle':'defaultStyle'">
  19. <i :class="[item.icon,currentIndex===index?'selectFontStyle':'']" />
  20. </el-avatar>
  21. <div style="margin-top: 5rem; font-size: 14rem;" :class="currentIndex===index?'selectFontStyle':''">{{item.label}}</div>
  22. </el-col>
  23. </el-row>
  24. <div class="jt-btn" style="margin: 8rem;">
  25. <el-button color="rgb(255 100 100)" @click="clearMeasurementData"><span style="color: #fff;width: 300rem;">清空测量数据</span></el-button>
  26. </div>
  27. </div>
  28. </template>
  29. <script>
  30. let jt3d = undefined;
  31. let popup = undefined;
  32. export default {
  33. props: {
  34. },
  35. watch: {
  36. },
  37. /* 数据 */
  38. data() {
  39. return {
  40. currentIndex: -1,
  41. measure: [{
  42. label: '长度测量(贴地)',
  43. type: 'measureLength',
  44. number: 0,
  45. icon: 'iconfont icon-thin-_pencil_rul'
  46. },
  47. {
  48. label: '面积测量(贴地)',
  49. type: 'measureArea',
  50. number: 1,
  51. icon: 'iconfont icon-svgmianjiceliang'
  52. },
  53. {
  54. label: '高度测量',
  55. type: 'measureHeight',
  56. number: 2,
  57. icon: 'iconfont icon-svggaoduceliang'
  58. },
  59. {
  60. label: '空间距离',
  61. type: 'measureSpatialLength',
  62. number: 3,
  63. icon: 'iconfont icon-svgkongjianceliang'
  64. },
  65. {
  66. label: '三角测量',
  67. type: 'measureTriangle',
  68. number: 4,
  69. icon: 'iconfont icon-svgsanjiaoceliang'
  70. },
  71. {
  72. label: '坐标测量',
  73. type: 'pickUp',
  74. number: 5,
  75. icon: 'iconfont icon-svgzuobiaoceliang'
  76. },
  77. ],
  78. }
  79. },
  80. /* 方法 */
  81. methods: {
  82. /**
  83. * 测量事件
  84. * @param {Object} type 测量类型
  85. * @param {Object} index 第几个被选中
  86. */
  87. handleMeasure(type, index) {
  88. this.currentIndex = index;
  89. //移除左键单击事件
  90. if (jt3d.handlerLeftClick) {
  91. jt3d.handlerLeftClick.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
  92. }
  93. jt3d.CommonTools.clear();
  94. switch (type) {
  95. case "measureLength": //长度测量(贴地)
  96. jt3d.CommonTools.measureLength(function(error) {
  97. ElMessage.error(error)
  98. });
  99. break;
  100. case "measureArea": //面积测量(贴地)
  101. jt3d.CommonTools.measureArea(function(error) {
  102. ElMessage.error(error)
  103. });
  104. break;
  105. case "measureHeight": //高度测量
  106. jt3d.CommonTools.measureHeight()
  107. break;
  108. case "measureSpatialLength": //空间距离
  109. jt3d.CommonTools.measureSpatialLength(function(error) {
  110. ElMessage.error(error)
  111. });
  112. break;
  113. case "measureTriangle": //三角测量
  114. jt3d.CommonTools.measureTriangle()
  115. break;
  116. case "pickUp": //坐标测量
  117. ElMessage("点击位置开始测量");
  118. this.pickUp();
  119. break;
  120. }
  121. },
  122. /**
  123. * 坐标测量
  124. */
  125. pickUp() {
  126. let _self = this;
  127. if (popup) {
  128. popup.close();
  129. }
  130. jt3d.SketchViewModel.sketchTools('point', {
  131. onComplete(cPoint, gPoint) {
  132. if (gPoint.lng) {
  133. let html = "";
  134. html += "<div style='text-align: left;'>";
  135. html += "<p>经度:" + gPoint.lng.toFixed(6) + "</p>";
  136. html += "<p>纬度:" + gPoint.lat.toFixed(6) + "</p>";
  137. html += "<p>高度:" + gPoint.height.toFixed(2) + "米</p>";
  138. html += "</div>";
  139. let position = {
  140. x: Number(gPoint.lng),
  141. y: Number(gPoint.lat),
  142. z: Number(gPoint.height)
  143. }
  144. // popup = new jt3dSDK.PopupWindow.HtmlWindow(window["viewer"], position, "位置信息", html,40);
  145. popup = new jt3dSDK.PopupWindow.HtmlWindow(window["viewer"], cPoint, "位置信息", html, -30);
  146. }
  147. },
  148. onError(message) {
  149. }
  150. });
  151. },
  152. /**
  153. * 清空测量数据
  154. */
  155. clearMeasurementData() {
  156. this.currentIndex = -1;
  157. jt3d.CommonTools.clear();
  158. if (popup) {
  159. popup.close();
  160. }
  161. //还原左键单击事件
  162. this.$parent.$parent.$refs.refMap3d.clickEntity(jt3d);
  163. },
  164. },
  165. mounted() {
  166. }
  167. };
  168. </script>
  169. <style lang="scss" scoped>
  170. .el-avatar{
  171. width: 70rem !important;
  172. height: 70rem !important;
  173. font-size: 14px !important;
  174. cursor: pointer;
  175. }
  176. .el-button{
  177. height: 32rem;
  178. font-size: 16rem;
  179. padding: 8rem 15rem;
  180. }
  181. .jt-measure {
  182. .el-col {
  183. padding: 10rem;
  184. // color: rgba(90, 172, 255, 1.0);
  185. color: #fff;
  186. }
  187. i {
  188. display: inline-block;
  189. width: 100%;
  190. height: 36rem;
  191. line-height: 36rem;
  192. text-align: center;
  193. border-radius: 5rem;
  194. font-size: 40rem;
  195. // color: rgba(90, 172, 255, 1.0);
  196. color: #fff;
  197. transition: all .3s;
  198. -webkit-transition: all .3s
  199. }
  200. .selectStyle {
  201. // background: rgba(135, 182, 254, 0.5);
  202. background: rgb(0 44 126);
  203. --el-avatar-size: 70rem !important;
  204. }
  205. .defaultStyle {
  206. background: #ffffff00;
  207. --el-avatar-size: 70rem !important;
  208. }
  209. .selectFontStyle {
  210. color: #fff;
  211. }
  212. }
  213. </style>