trajectory.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <div style="height: 100vh">
  3. <van-nav-bar
  4. title="工作轨迹"
  5. left-text="返回"
  6. left-arrow
  7. @click-left="goBack()"
  8. />
  9. <div
  10. id="map-container"
  11. style="width: 100%; height: calc(100vh - 46px)"
  12. ></div>
  13. </div>
  14. </template>
  15. <script>
  16. import { getTrack } from "@/api";
  17. import { Notify } from "vant";
  18. export default {
  19. name: "trajectory",
  20. components: {},
  21. data() {
  22. return {
  23. recordId: "",
  24. };
  25. },
  26. created() {
  27. this.recordId = this.$route.query.recordId;
  28. },
  29. mounted() {
  30. let that = this
  31. getTrack({ recordId: this.recordId }).then((res) => {
  32. if (res.status == 10000) {
  33. const map = new AMap.Map("map-container");
  34. // 如果为圆形
  35. map.setCenter(
  36. new AMap.LngLat(res.data.coordPoint.log, res.data.coordPoint.lat)
  37. );
  38. map.setZoom(13);
  39. map.add(
  40. new AMap.Polyline({
  41. path: res.data.guijicoord.map((item) => {
  42. return new AMap.LngLat(item.log, item.lat);
  43. }),
  44. strokeWeight: 6,
  45. strokeColor: "#ee0a24",
  46. lineJoin: "round",
  47. lineCap: "round",
  48. showDir: true,
  49. })
  50. );
  51. if (res.data.fenceType == 0) {
  52. map.add(
  53. new AMap.Circle({
  54. center: new AMap.LngLat(
  55. res.data.coordPoint.log,
  56. res.data.coordPoint.lat
  57. ),
  58. radius: parseFloat(res.data.fenceRadii),
  59. fillColor: "#409eff66",
  60. strokeColor: "#409eff",
  61. strokeWeight: 1,
  62. })
  63. );
  64. } else {
  65. map.add(
  66. new AMap.Polygon({
  67. path: res.data.coordPointList.map((item) => {
  68. return [item.log, item.lat];
  69. }),
  70. fillColor: "#409eff66",
  71. borderWeight: 1,
  72. strokeColor: "#409eff",
  73. })
  74. );
  75. }
  76. } else {
  77. Notify({ type: "warning", message: res.message || "查看轨迹信息失败",duration:1000 });
  78. setTimeout(()=>that.$router.back(),1000)
  79. }
  80. });
  81. },
  82. methods: {
  83. goBack() {
  84. this.$router.back();
  85. },
  86. },
  87. };
  88. </script>
  89. <style scoped lang="scss">
  90. $white: #fff;
  91. .van-nav-bar {
  92. background: #67a2ff;
  93. }
  94. /deep/ .van-icon {
  95. color: $white;
  96. }
  97. /deep/ .van-nav-bar__text {
  98. color: $white;
  99. }
  100. /deep/ .van-nav-bar__title {
  101. color: $white;
  102. }
  103. </style>