ggsbtj.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <script setup>
  2. import {
  3. inject
  4. } from "vue";
  5. import html2canvas from 'html2canvas';
  6. import {
  7. blobToBase64,
  8. base64ToBlob
  9. } from '@/assets/js/blobtobase64';
  10. const getMapInstance = inject("getMapInstance");
  11. jt3d = getMapInstance();
  12. </script>
  13. <template>
  14. </template>
  15. <script>
  16. let jt3d = undefined;
  17. export default {
  18. data() {
  19. return {
  20. // viewersName: '', //视角标签名称
  21. // ImgurlList: [], //截图地址列表
  22. }
  23. },
  24. methods: {
  25. //获取输入框值
  26. getName() {
  27. this.viewersName = document.getElementById("inputValue").value;
  28. },
  29. //跳转方法
  30. flyto(options) {
  31. jt3d.LocateUtil.flyToPoint(options)
  32. },
  33. //删除方法,传keyvalue以及需要修改属性
  34. deleteviewer(item, index) {
  35. //删除对应数组内的对象
  36. this.ImgurlList.splice(index, 1)
  37. if (item.id) {
  38. this.$http.get('/delete', {
  39. tableName: 'sys_map_angle',
  40. keyValue: item.id,
  41. }).then(res => {
  42. console.log(res.data)
  43. })
  44. }
  45. },
  46. //添加视角标签,当前页存数组,向数据库传入相机参数
  47. addviewer() {
  48. //获取当前界面截图方法
  49. html2canvas(
  50. this.$parent.$parent.$refs.refMap3d.$refs.cesiumContainer, {
  51. // backgroundColor: null, //画出来的图片有白色的边框,不要可设置背景为透明色(null)
  52. useCORS: true, //支持图片跨域
  53. scale: 1 / 8, //设置放大的倍数
  54. }
  55. ).then(canvas => {
  56. //截图用img元素承装,显示在页面的上
  57. let url = canvas.toDataURL('image/png')
  58. //经纬度、高度
  59. // 获取 相机姿态信息
  60. let heading = window["viewer"].scene.camera.heading
  61. let pitch = window["viewer"].scene.camera.pitch
  62. let roll = window["viewer"].scene.camera.roll
  63. let position = window["viewer"].scene.camera.positionCartographic
  64. let longitude = Cesium.Math.toDegrees(position.longitude) //y
  65. let latitude = Cesium.Math.toDegrees(position.latitude) //x
  66. let height = position.height
  67. let info = {
  68. latitude: latitude,
  69. longitude: longitude,
  70. height: height,
  71. pitch: Cesium.Math.toDegrees(pitch),
  72. roll: Cesium.Math.toDegrees(roll),
  73. heading: Cesium.Math.toDegrees(heading)
  74. }
  75. //dom for循环渲染列表
  76. this.ImgurlList.unshift({
  77. url: url,
  78. name: this.viewersName,
  79. info: info
  80. })
  81. //base64转换为二进制文件
  82. // let blob = base64ToBlob(url)
  83. // //文件转为文件流
  84. // let formData = new FormData();
  85. // formData.append('file',blob)
  86. let data = {
  87. name: this.viewersName,
  88. x: latitude,
  89. y: longitude,
  90. z: height,
  91. pitch: Cesium.Math.toDegrees(pitch),
  92. roll: Cesium.Math.toDegrees(roll),
  93. heading: Cesium.Math.toDegrees(heading),
  94. screenshot: url,
  95. userId: this.id,
  96. // id:0
  97. }
  98. //添加数据接口
  99. this.$http.post('/postSubmit', {
  100. tableName: 'sys_map_angle',
  101. keyValue: '',
  102. formData: data,
  103. }).then(res => {
  104. console.log(res)
  105. if (res.success == true) {
  106. }
  107. })
  108. }).catch(err => {
  109. console.log(err)
  110. })
  111. },
  112. searchviewer() {
  113. this.info = JSON.parse(localStorage.getItem('person'))
  114. this.id = this.info.id
  115. //获取所有图片数据
  116. this.$http.get('/getTableList', {
  117. tableName: 'sys_map_angle', //
  118. sqlWhere: "name like '%" + this.viewersName + "%'",
  119. orderByField: ''
  120. }).then(res => {
  121. console.log('获取图片', res.data)
  122. this.ImgurlList = [];
  123. res.data.forEach(item => {
  124. let info = {
  125. latitude: item.x,
  126. longitude: item.y,
  127. height: item.z,
  128. pitch: item.pitch,
  129. roll: item.roll,
  130. heading: item.heading
  131. }
  132. // let url = blobToBase64(item.screenshot)
  133. //dom for循环渲染列表
  134. this.ImgurlList.push({
  135. url: item.screenshot,
  136. name: item.name,
  137. info: info,
  138. id: item.id
  139. })
  140. })
  141. // console.log('img列表',this.ImgurlList)
  142. })
  143. }
  144. },
  145. mounted() {
  146. this.info = JSON.parse(localStorage.getItem('person'))
  147. this.id = this.info.id
  148. //获取所有图片数据
  149. this.$http.get('/getTableList', {
  150. tableName: 'sys_map_angle', //
  151. sqlWhere: '', //+ this.loginForm.id
  152. orderByField: ''
  153. }).then(res => {
  154. console.log('获取图片', res.data)
  155. res.data.forEach(item => {
  156. let info = {
  157. latitude: item.x,
  158. longitude: item.y,
  159. height: item.z,
  160. pitch: item.pitch,
  161. roll: item.roll,
  162. heading: item.heading
  163. }
  164. // let url = blobToBase64(item.screenshot)
  165. //dom for循环渲染列表
  166. this.ImgurlList.push({
  167. url: item.screenshot,
  168. name: item.name,
  169. info: info,
  170. id: item.id
  171. })
  172. })
  173. // console.log('img列表',this.ImgurlList)
  174. })
  175. }
  176. }
  177. </script>
  178. <style lang="scss" scoped>
  179. .mainview {
  180. width: 100%;
  181. height: 100%;
  182. .header {
  183. width: 100%;
  184. display: flex;
  185. input,
  186. input:focus {
  187. outline: none;
  188. width: 185rem !important;
  189. border: 1rem solid rgba(255, 255, 255, 0.8);
  190. margin-right: 10rem;
  191. height: 26rem !important;
  192. color: rgba(255, 255, 255, 1);
  193. background-color: rgba(255, 255, 255, 0) !important;
  194. border-radius: 3rem;
  195. }
  196. }
  197. .middleviewer {
  198. width: 265rem;
  199. height: 100%;
  200. margin-left: 7rem;
  201. .viewer {
  202. width: 265rem !important;
  203. height: 196rem !important;
  204. margin-top: 15rem;
  205. border: 1rem solid #ffffff !important;
  206. border-radius: 1rem !important;
  207. .viewertop {
  208. width: 265rem !important;
  209. height: 166rem !important;
  210. img {
  211. width: 100% !important;
  212. height: 100% !important;
  213. }
  214. }
  215. .viewerbottom {
  216. line-height: 30rem !important;
  217. text-align: center !important;
  218. width: 265rem !important;
  219. height: 30rem !important;
  220. position: relative;
  221. background-color: rgba(15, 145, 185, 0.7);
  222. .deleteImg {
  223. width: 24rem;
  224. height: 24rem;
  225. right: 5rem;
  226. top: 3rem;
  227. position: absolute;
  228. }
  229. }
  230. }
  231. }
  232. }
  233. ::v-deep .el-input {
  234. flex-grow: 0 !important;
  235. width: 200rem !important;
  236. // display: inline !important;
  237. // margin-left: 5rem;
  238. margin-right: 10rem;
  239. height: 30rem !important;
  240. }
  241. //输入框文字颜色
  242. ::v-deep .el-input__inner {
  243. color: rgba(255, 255, 255, 1)
  244. }
  245. //输入框背景色
  246. ::v-deep .el-input__wrapper {
  247. background-color: rgba(255, 255, 255, 0) !important;
  248. }
  249. ::v-deep .el-button {
  250. border-radius: 3rem !important;
  251. }
  252. ::v-deep .el-button--primary {
  253. background-color: rgba(64, 158, 255, 0.6) !important;
  254. }
  255. ::-webkit-scrollbar {
  256. width: 0rem;
  257. }
  258. </style>