CockpitVector.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <div class="CockpitVectorBox">
  3. <div class="cockpit_vector">
  4. <div class="list_vector list_vector_multi" v-for="(item, index ) in store.state.vectorData" :key="index"
  5. v-if="item.name != 'geom' && item.name != 'id' && item.name != 'type'">
  6. <div class="filed_box">
  7. {{ item.name }}
  8. </div>
  9. :
  10. <div class="filed_box">
  11. {{ item.value }}
  12. </div>
  13. </div>
  14. </div>
  15. </div>
  16. </template>
  17. <script>
  18. //这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  19. import { QueryList } from '@/api/cockpitNew'
  20. import * as wellknown from "wellknown";
  21. import * as turf from "@turf/turf";
  22. let pick_entity = null;
  23. export default {
  24. components: {},
  25. data() {
  26. return {
  27. restaurants: [],
  28. state: '',
  29. timeout: null,
  30. pick_entity: null,
  31. };
  32. },
  33. //监听属性 类似于data概念
  34. computed: {},
  35. //监控data中的数据变化
  36. watch: {},
  37. //方法集合
  38. methods: {
  39. build_data(geojson) {
  40. geojson.coordinates.forEach((res) => {
  41. const twoDArray = res[0];
  42. const oneDArray = twoDArray.reduce((accumulator, currentValue) => accumulator.concat(currentValue), []);
  43. pick_entity.entities.add({
  44. polygon: {
  45. // 获取指定属性(positions,holes(图形内需要挖空的区域))
  46. hierarchy: {
  47. positions: Cesium.Cartesian3.fromDegreesArrayHeights(oneDArray),
  48. },
  49. // 边框
  50. outline: true,
  51. // 边框颜色
  52. outlineColor: Cesium.Color.RED,
  53. // 边框尺寸
  54. outlineWidth: 2,
  55. // 填充的颜色,withAlpha透明度
  56. material: Cesium.Color.GREEN.withAlpha(0),
  57. // 是否被提供的材质填充
  58. fill: true,
  59. // 恒定高度
  60. height: 1.1,
  61. // 显示在距相机的距离处的属性,多少区间内是可以显示的
  62. // distanceDisplayCondition: new Cesium.DistanceDisplayCondition(1000, 10000000),
  63. // 是否显示
  64. show: true,
  65. // 顺序,仅当`clampToGround`为true并且支持地形上的折线时才有效。
  66. zIndex: 10
  67. }
  68. });
  69. // 注意:polygon首尾坐标要一致
  70. var polygon = turf.polygon([twoDArray]);
  71. var centroid = turf.centroid(polygon).geometry.coordinates;
  72. viewer.camera.flyTo({
  73. duration: 1,
  74. destination: Cesium.Cartesian3.fromDegrees(centroid[0], centroid[1], 3000),
  75. // destination: {
  76. // x: -6283267.004204832,
  77. // y: 28123682.896774407,
  78. // z: 23709669.98539126
  79. // },
  80. orientation: {
  81. heading: 6.149339593573709,
  82. pitch: -1.539825618847483,
  83. roll: 0
  84. },
  85. });
  86. })
  87. },
  88. },
  89. beforeCreate() { }, //生命周期 - 创建之前
  90. created() { }, //生命周期 - 创建完成(可以访问当前this实例)
  91. beforeMount() { }, //生命周期 - 挂载之前
  92. mounted() {
  93. const that = this;
  94. this.$nextTick(() => {
  95. pick_entity = new Cesium.CustomDataSource("pick_entity");
  96. viewer.dataSources.add(pick_entity);
  97. }); //生命周期 - 挂在完成
  98. }, //生命周期 - 挂在完成
  99. beforeUpdate() { }, //生命周期 - 更新之前
  100. updated() { }, //生命周期 - 更新之后
  101. beforeDestroy() { }, //生命周期 - 销毁之前
  102. destroy() { },//生命周期 - 销毁完成
  103. activated() { }, //若组件实例是 <KeepAlive> 缓存树的一部分,当组件被插入到 DOM 中时调用。
  104. deactivated() { } //若组件实例是 <KeepAlive> 缓存树的一部分,当组件从 DOM 中被移除时调用。
  105. };
  106. </script>
  107. <style scoped lang="scss">
  108. .CockpitVectorBox {
  109. // color: #198ec0;
  110. }
  111. .list_vector {
  112. background-image: url("/static/images/ghzc/内容框.png");
  113. width: 20rem;
  114. border-top: 1px solid #CCC;
  115. font-size: 14px;
  116. padding: 1rem;
  117. // border-bottom:1px solid #CCC ;
  118. }
  119. .list_vector:last-child {
  120. border-bottom: 1px solid #CCC;
  121. }
  122. .cockpit_vector {
  123. position: absolute;
  124. top: 6rem;
  125. width: 20rem;
  126. height: 35rem;
  127. overflow: auto;
  128. overflow-x: hidden;
  129. // z-index: -1;
  130. }
  131. /deep/.el-input__inner:focus {
  132. border: 1px solid #1fb1ef;
  133. }
  134. /deep/.el-input__inner {
  135. border: 1px solid #1fb1ef;
  136. background: rgba(0, 80, 111, 0.8);
  137. border-radius: 18px;
  138. height: 30px;
  139. color: white;
  140. line-height: 30px;
  141. // background: #ffffff3b;
  142. }
  143. /deep/.el-input__icon {
  144. line-height: 30px;
  145. border-radius: 0 18px 18px 0;
  146. cursor: pointer;
  147. }
  148. /deep/.el-input__suffix {
  149. background: #1fb1ef;
  150. right: 1px;
  151. padding: 0 5px;
  152. border-radius: 0 18px 18px 0;
  153. opacity: 0.8;
  154. color: #fff;
  155. }
  156. /deep/ .el-autocomplete-suggestion {
  157. margin-top: 8px;
  158. border-radius: 6px;
  159. border: 1px solid #198ec0;
  160. background: rgba(0, 80, 111, 0.6);
  161. color: rgba(25, 142, 192, 1);
  162. .popper__arrow {
  163. top: -8px;
  164. border-bottom-color: rgba(31, 177, 239, 1);
  165. }
  166. .popper__arrow::after {
  167. border-bottom-color: rgba(0, 80, 111, 0.9);
  168. }
  169. .el-autocomplete-suggestion__wrap {
  170. padding: 2px;
  171. }
  172. }
  173. /deep/ .el-autocomplete-suggestion li {
  174. color: #ffffff;
  175. }
  176. /deep/ .el-autocomplete-suggestion li:hover {
  177. background-color: rgba(8, 162, 223, 0.8);
  178. border-radius: 6px;
  179. }
  180. .list_vector_multi {
  181. background-image: url("/static/images/ghzc/内容框.png");
  182. width: 20rem;
  183. border-top: 1px solid #CCC;
  184. font-size: 14px;
  185. padding: 0.5rem 0rem 0.5rem 0rem;
  186. border-left: 1px solid #CCC;
  187. border-right: 1px solid #CCC;
  188. }
  189. .list_vector_multi:last-child {
  190. border-bottom: 1px solid #CCC;
  191. }
  192. .filed_box {
  193. display: inline-block;
  194. }
  195. </style>