ed8a1a0a71a7715804bab1999519db4431468e15.svn-base 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <div id="SimpleMarker" ref="SimpleMarker" class="SimpleMarker">
  3. <div id="locateMarker" ref="locateMarker" class="locateMarker" v-show="iconShow"></div>
  4. <div id="oneMarker" ref="oneMarker" class="oneMarker" v-show="oneShow"></div>
  5. <div id="towMarker" ref="towMarker" class="towMarker" v-show="towShow"></div>
  6. </div>
  7. </template>
  8. <script>
  9. import 'ol/ol.css';
  10. import Overlay from "ol/Overlay";
  11. export default {
  12. name: "SimpleMarker",
  13. props: {
  14. },
  15. data: function() {
  16. return {
  17. iconShow: false,
  18. oneShow: false,
  19. towShow: false,
  20. locate: {},
  21. locateOne: {},
  22. locateTow: {},
  23. map:{},
  24. }
  25. },
  26. inject: ['baseMap'],
  27. methods: {
  28. init(coords) {
  29. this.map = this.baseMap.map;
  30. if (!this.map) {
  31. return
  32. }
  33. if (!this.map.getOverlayById('locate')) {
  34. this.locate = new Overlay({
  35. id: 'locate',
  36. stopEvent: false,
  37. });
  38. this.map.addOverlay(this.locate);
  39. }
  40. this.locate.setElement(this.$refs.locateMarker);
  41. this.setMarkerPosition(coords,this.locate);
  42. this.hideMarker();
  43. this.iconShow=true;
  44. },
  45. init2(coords) {
  46. this.map = this.baseMap.map;
  47. if (!this.map) {
  48. return
  49. }
  50. if (!this.map.getOverlayById('locateOne')) {
  51. this.locateOne = new Overlay({
  52. id: 'locateOne',
  53. stopEvent: false,
  54. });
  55. this.map.addOverlay(this.locateOne);
  56. }
  57. if (!this.map.getOverlayById('locateTow')) {
  58. this.locateTow = new Overlay({
  59. id: 'locateTow',
  60. stopEvent: false,
  61. });
  62. this.map.addOverlay(this.locateTow);
  63. }
  64. this.locateOne.setElement(this.$refs.oneMarker);
  65. this.setMarkerPosition(coords[0],this.locateOne);
  66. this.locateTow.setElement(this.$refs.towMarker);
  67. this.setMarkerPosition(coords[1],this.locateTow);
  68. this.hideMarker();
  69. this.towShow=true;
  70. this.oneShow=true;
  71. },
  72. setMarkerPosition(coords,locate) {
  73. locate.setPosition(coords);
  74. },
  75. showMarker(iconShow) {
  76. console.log(iconShow)
  77. iconShow = true;
  78. console.log(iconShow)
  79. },
  80. hideMarker(iconShow) {
  81. if(!iconShow){
  82. this.iconShow=false;
  83. this.oneShow=false;
  84. this.towShow=false;
  85. }else {
  86. iconShow = false;
  87. }
  88. }
  89. }
  90. }
  91. </script>
  92. <style scoped>
  93. .locateMarker {
  94. width: 48px;
  95. height: 48px;
  96. background-image: url("../../../assets/locate-red.png");
  97. background-size: 48px;
  98. z-index: 100;
  99. position: relative;
  100. left: -24px;
  101. top: -45px;
  102. pointer-events: none;
  103. }
  104. .oneMarker {
  105. width: 32px;
  106. height: 50px;
  107. background-image: url("../../../assets/result1.png");
  108. background-size: 32px;
  109. z-index: 100;
  110. position: relative;
  111. left: -16px;
  112. top: -47px;
  113. pointer-events: none;
  114. }
  115. .towMarker {
  116. width: 32px;
  117. height: 50px;
  118. background-image: url("../../../assets/result2.png");
  119. background-size: 32px;
  120. z-index: 100;
  121. position: relative;
  122. left: -16px;
  123. top: -47px;
  124. pointer-events: none;
  125. }
  126. </style>