trail-dialog.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <el-dialog
  3. title="巡检任务轨迹"
  4. :visible.sync="centerDialogVisible"
  5. width="70vw"
  6. @closed="onDialogClose"
  7. >
  8. <div v-if="!destroyed" class="trail-dialog-content" style="width: 100%;height: 70vh;">
  9. <bd-map :loaded="loaded" map-id="room-map"/>
  10. <div class="map-ctrl">
  11. <el-button type="primary" @click="trailPlay">轨迹播放</el-button>
  12. <el-button type="primary" @click="showTrailTime">轨迹时间</el-button>
  13. </div>
  14. </div>
  15. </el-dialog>
  16. </template>
  17. <script>
  18. import BdMap from '@/components/map/index.vue';
  19. import maphandle from '@/components/map/maphandle';
  20. import position from '@/views/bd/realtimeLocation/icon/position.png';
  21. import dayjs from 'dayjs';
  22. // import {uuid} from "@/utils";
  23. export default {
  24. name: 'trail-dialog',
  25. mixins: [maphandle],
  26. components: {
  27. BdMap
  28. },
  29. data() {
  30. return {
  31. centerDialogVisible: false,
  32. locationMarkers: {},
  33. mapIns: null,
  34. fencePolyLayer: null,
  35. trail: {},
  36. destroyed: false,
  37. playLine: null
  38. };
  39. },
  40. // 组件卸载前清空图层信息
  41. beforeDestroy() {
  42. this.markLayer && this.mapIns.removeLayersById('markerLayer');
  43. this.fencePolyLayer && this.fencePolyLayer.cust.clearLayer()
  44. },
  45. created() {
  46. },
  47. mounted() {
  48. },
  49. methods: {
  50. dayjs,
  51. onDialogClose() {
  52. this.markLayer = null;
  53. this.destroyed = true;
  54. },
  55. loaded(map) {
  56. this.markLayer = new BDLayers.Lib.Layer.CBVectorLayer('markerLayer', true);
  57. map.addCustomLayers(this.markLayer, 99);
  58. this.mapIns = map;
  59. map.setPitch(0);
  60. map.setCenter([118.86895, 32.01326]);
  61. this.fencePolyLayer = this.createLayer(map);
  62. this.addTrail()
  63. },
  64. show(data) {
  65. this.trail = data;
  66. this.destroyed = false;
  67. this.centerDialogVisible = true;
  68. },
  69. addTrail(data) {
  70. const coordinates = [
  71. [118.868474555524, 32.013913750075],
  72. [118.868459917135, 32.0138560330253],
  73. [118.868460650064, 32.0137600494265],
  74. [118.868469791963, 32.0135491295906],
  75. [118.868450597046, 32.0135969285238],
  76. [118.868451821878, 32.0134372342673],
  77. [118.868369085172, 32.0134271059761],
  78. [118.868229813542, 32.0134261784667],
  79. [118.868037844538, 32.0134249000077],
  80. [118.867988911263, 32.013424574126],
  81. [118.867990212059, 32.0132809893746],
  82. [118.867986825628, 32.0132395072755],
  83. [118.867987028075, 32.0132171885197],
  84. [118.867987432888, 32.0131725599655],
  85. [118.867984539806, 32.0130769425047],
  86. [118.867977454441, 32.0130291167663],
  87. [118.86797791828, 32.0129781711549],
  88. [118.867978150146, 32.0129527041872],
  89. [118.867974855578, 32.0129017568948],
  90. [118.868046176274, 32.0129117791912],
  91. [118.868121507934, 32.0128931867922],
  92. [118.868117943319, 32.0128708893801],
  93. [118.868126616248, 32.012737367597],
  94. [118.868127634971, 32.0126197858525],
  95. [118.868127662494, 32.0126166091195],
  96. [118.868165320753, 32.0126041528561],
  97. [118.868173101262, 32.0125724412675],
  98. [118.868240681514, 32.0125728913369],
  99. [118.868308235972, 32.0125765173023],
  100. [118.868334874981, 32.0125322352762],
  101. [118.868324305199, 32.012446455205],
  102. [118.868361835438, 32.0124467051483],
  103. [118.868364679658, 32.0125610134717],
  104. [118.868492254263, 32.0125713907483],
  105. [118.868541014618, 32.0125780675563],
  106. [118.868732580782, 32.012566639437],
  107. [118.868841456955, 32.0125673645282],
  108. [118.868976574771, 32.0125746162152],
  109. [118.869070453844, 32.0125720654824],
  110. [118.869096734551, 32.0125722405062],
  111. [118.869156822422, 32.0125694647922],
  112. [118.869179313588, 32.0125759664106],
  113. [118.869201684821, 32.0126047016424],
  114. [118.869186178487, 32.0126935647542],
  115. [118.869193065594, 32.0128080658432],
  116. [118.869192510216, 32.0129098661745],
  117. [118.86919198924, 32.0130053604978],
  118. [118.869179854563, 32.0131613771548],
  119. [118.869190250492, 32.0133240705021],
  120. [118.869185964264, 32.0134197772962],
  121. [118.86917071489, 32.0134547924615],
  122. [118.869159014503, 32.0135281642937],
  123. [118.869166174307, 32.0135953030259],
  124. [118.869165521059, 32.0137135723353],
  125. [118.869187426642, 32.0138416759025],
  126. [118.869153188005, 32.0138990608231],
  127. [118.868990969654, 32.0139203908971],
  128. [118.868768561862, 32.0139189097324],
  129. [118.868572541435, 32.0139176042992],
  130. [118.868557462941, 32.0139175038812],
  131. ];
  132. // 19FB03
  133. this.playLine = bdmap.comp.Trajectory.loadTrajectory({
  134. mapView: this.mapIns,
  135. latlons: coordinates,
  136. unitTime: 500,
  137. speedValue: 1,
  138. mapToCenter: false,
  139. });
  140. bdmap.comp.Trajectory.trajectoryPlay(this.playLine);
  141. },
  142. showTrailTime(data) {
  143. let location = [
  144. {
  145. lnglat: [118.868240681514, 32.0125728913369],
  146. date: '2024-12-11 06:10:00',
  147. },
  148. {
  149. lnglat: [118.869096734551, 32.0125722405062],
  150. date: '2024-12-11 06:13:00',
  151. },
  152. {
  153. lnglat: [118.869179854563, 32.0131613771548],
  154. date: '2024-12-11 06:15:30',
  155. },
  156. {
  157. lnglat: [118.868768561862, 32.0139189097324],
  158. date: '2024-12-11 06:25:33',
  159. }
  160. ]
  161. this.markLayer && this.markLayer.removeAll();
  162. location.forEach((item, i) => {
  163. const {
  164. lnglat,
  165. date,
  166. } = item;
  167. this.markLayer.addMarker(new BDLayers.Lib.Overlays.MarkerImg(
  168. `marker${date + i}`,
  169. lnglat,
  170. {
  171. imgurl: position,
  172. iconSize: [25, 30],
  173. labelText: `${date}`,
  174. labelTextColor: '#fff',
  175. labelTextSize: 10,
  176. },
  177. ));
  178. }
  179. );
  180. },
  181. trailPlay() {
  182. bdmap.comp.Trajectory.trajectoryCancel(this.playLine);
  183. bdmap.comp.Trajectory.trajectoryPlay(this.playLine);
  184. },
  185. },
  186. };
  187. </script>
  188. <style scoped lang="scss">
  189. .trail-dialog-content {
  190. display: flex;
  191. justify-content: center;
  192. align-items: center;
  193. .map-ctrl {
  194. display: flex;
  195. height: 100%;
  196. flex-direction: column;
  197. justify-content: flex-start;
  198. align-items: flex-start;
  199. margin-left: 20px;
  200. .el-button {
  201. margin-left: 0;
  202. margin-top: 10px;
  203. }
  204. }
  205. }
  206. </style>