index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <pannel class="rooms-container">
  3. <template v-slot:title>
  4. 室内定位
  5. </template>
  6. <template v-slot:action>
  7. </template>
  8. <template v-slot:content>
  9. <div class="location-list">
  10. <template v-for="room in roomList">
  11. <div :key="`room_${room.id}`" class="list-item">
  12. <span class="over-flow-hidden" style="width: 80%">
  13. {{ room.room }}
  14. </span>
  15. <span class="over-flow-hidden" style="width: 20%">
  16. </span>
  17. </div>
  18. </template>
  19. <socket-message :onMessage="onMessage" :ws="ws"></socket-message>
  20. </div>
  21. </template>
  22. </pannel>
  23. </template>
  24. <script>
  25. import SocketMessage from '@/components/WebsocketMessage/index.vue';
  26. import { uuid } from '@/utils';
  27. import maphandle from '@/views/bd/map/maphandle';
  28. import Pannel from '@/views/bd/pannel/index.vue';
  29. import dayjs from 'dayjs';
  30. import room_location from './icon/room_location.jpg';
  31. export default {
  32. name: 'room-location',
  33. mixins: [maphandle],
  34. components: {
  35. SocketMessage,
  36. Pannel,
  37. },
  38. data() {
  39. return {
  40. roomList: [],
  41. fp: null,
  42. ws: null,
  43. markLayer: null,
  44. markLayerId: '',
  45. };
  46. },
  47. // 组件卸载前清空图层信息
  48. beforeDestroy() {
  49. this.markLayer && window.map.removeLayersById(this.markLayerId);
  50. },
  51. created() {
  52. if (this.markLayer) {
  53. return;
  54. }
  55. this.markLayerId = `real_time_markerLayer${uuid()}`;
  56. this.markLayer = new BDLayers.Lib.Layer.CBVectorLayer(this.markLayerId, {
  57. enableAltitude: true,
  58. });
  59. window.map.addCustomLayers(this.markLayer, 5);
  60. },
  61. mounted() {
  62. this.getRoom();
  63. },
  64. methods: {
  65. dayjs,
  66. getRoom() {
  67. this.roomList = [
  68. {
  69. id: 1,
  70. room: '创研院C4',
  71. poly: 'POLYGON((118.869042069359 32.0131156239015, 118.86839482667 32.0131180416999, 118.868399686907 32.0133391503578, 118.869046506393 32.0133281708171, 118.869042069359 32.0131156239015))',
  72. altitude: 11.4,
  73. },
  74. ];
  75. // this.roomList.forEach(item => {
  76. // const {
  77. // id,
  78. // room,
  79. // poly,
  80. // altitude,
  81. // } = item;
  82. // const polygon = this.drawPoly({
  83. // name: room,
  84. // altitude,
  85. // coordinates: this.polygonToCoordinates(poly),
  86. // bizAttr: {
  87. // id,
  88. // name: room,
  89. // },
  90. // });
  91. // });
  92. // var marker = new BDLayers.Lib.Overlays.UIMarker('marker00', [118.869042069359, 32.0131156239015],
  93. // {
  94. // 'draggable': false,
  95. // 'single': false,
  96. // 'content': `<div class="text_marker" style="color:#fff"><img src="${room_location}" width="40px" height="40px"/></div>`,
  97. // altitude: 800,
  98. // });
  99. var marker = new BDLayers.Lib.Overlays.MarkerImg(
  100. 'marker01',
  101. [118.869046506393,32.0133281708171], {
  102. imgurl: room_location,
  103. iconSize: [90, 54],
  104. altitude: 20,
  105. },
  106. );
  107. marker.on('click', () => {
  108. });
  109. this.markLayer.addMarker(marker);
  110. // marker.getMarker().addTo(window.map.map);
  111. },
  112. onMessage(a) {
  113. const data = JSON.parse(a.data);
  114. console.log('>>>>>>>>>>>>>>>>>>>>>>>>', data);
  115. this.$notify({
  116. title: '警告',
  117. message: `${data.msg.fenceName}发生闯禁事件。`,
  118. type: 'warning',
  119. });
  120. },
  121. },
  122. };
  123. </script>
  124. <style lang="scss" src="./index.scss" />