openDriver.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <div id="ThreeJS" class="three_div"></div>
  3. </template>
  4. <script>
  5. import {
  6. getStdMapMixin
  7. } from "@/mixin/workManagement/getStdMapMixin.js"
  8. import {
  9. openDriveMixin
  10. } from "@/mixin/workManagement/openDriveMixin.js"
  11. export default {
  12. name: "OpenDrive",
  13. mixins: [getStdMapMixin, openDriveMixin],
  14. components: {
  15. // vueQr,
  16. // glHome,
  17. },
  18. data() {
  19. return {
  20. isLoaded: false,
  21. lineArr:[]
  22. };
  23. },
  24. props: {
  25. mapId: {
  26. type: String,
  27. default: () => ""
  28. },
  29. startPoint: {
  30. type: Object,
  31. default: () => {}
  32. },
  33. endPoint: {
  34. type: Object,
  35. default: () => {}
  36. },
  37. sections: {
  38. type: Array,
  39. default: () =>[]
  40. }
  41. },
  42. methods: {
  43. changeMap(fileUrl) {
  44. this.onFileSelect(fileUrl);
  45. this.reloadOdrMap();
  46. },
  47. getMapDetails(mapId) {
  48. if(mapId == "2"){
  49. if(this.isLoaded == true){
  50. this.reloadNewMap("/map/mine4.xodr");
  51. }else{
  52. this.loadMap("/map/mine4.xodr");
  53. this.isLoaded = true;
  54. }
  55. return;
  56. }
  57. this.$axios({
  58. method: "post",
  59. url: this.$api.workManagement.mapDetails,
  60. data: {
  61. mapId
  62. }
  63. }).then((res) => {
  64. if (res.code == 200) {
  65. if(this.isLoaded == true){
  66. this.reloadNewMap(res.info.mapPath);
  67. }else{
  68. this.loadMap(res.info.mapPath);
  69. this.isLoaded = true;
  70. }
  71. }
  72. })
  73. }
  74. },
  75. mounted() {
  76. },
  77. updated() {
  78. },
  79. watch: {
  80. mapId: {
  81. handler(newVal, oldVal) {
  82. this.getMapDetails(newVal);
  83. }
  84. },
  85. startPoint: {
  86. handler(newVal, oldVal) {
  87. newVal.type="start";
  88. this.drawPoint(newVal);
  89. }
  90. },
  91. endPoint: {
  92. handler(newVal, oldVal) {
  93. newVal.type="end";
  94. this.drawPoint(newVal);
  95. }
  96. },
  97. sections: {
  98. handler(newVal, oldVal) {
  99. if(this.lineArr && this.lineArr.length > 0){
  100. this.lineArr.forEach((elem, index) => {
  101. this.clearColorLine(elem.roadId, elem.laneId);
  102. })
  103. this.clearPoint();
  104. }
  105. newVal.forEach((elem, index) => {
  106. this.fillColorLine(elem.roadId, elem.laneId);
  107. })
  108. this.lineArr = newVal;
  109. }
  110. }
  111. }
  112. };
  113. </script>
  114. <style scoped lang="less">
  115. .three_div {
  116. width: 100% !important;
  117. height: 100% !important;
  118. }
  119. /deep/ canvas {
  120. width: 100% !important;
  121. height: 100% !important;
  122. }
  123. </style>