ysltj.vue 6.9 KB

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