route.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <view>
  3. <map
  4. class="map"
  5. :latitude="item.lat"
  6. :longitude="item.lng"
  7. scale="11.3"
  8. :polyline="polyline"
  9. :polygons="polygon"
  10. :markers="markers"
  11. show-compass="true"
  12. ></map>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. data() {
  18. return {
  19. item: {},
  20. tab: [],
  21. current: 0,
  22. markers: [],
  23. polyline: [
  24. {
  25. arrowLine: true,
  26. width: 7,
  27. color: '#4CAF50',
  28. points: []
  29. }
  30. ],
  31. polygon: [
  32. {
  33. strokeWidth: 5,
  34. strokeColor: '#4CAF50',
  35. fillColor: '#03a9f482',
  36. points: []
  37. }
  38. ],
  39. circles: [
  40. {
  41. strokeWidth: 3,
  42. color: '#4CAF50',
  43. fillColor: '#03a9f482'
  44. }
  45. ]
  46. };
  47. },
  48. onLoad(e) {
  49. this.getData(e.id);//9
  50. },
  51. methods: {
  52. change(index) {
  53. this.current = index;
  54. this.refresh();
  55. },
  56. //获取数据
  57. getData(id) {
  58. this.$http.request({
  59. url: this.$http.urls.getMarkerList + id,
  60. success: res => {
  61. this.tab = res.data.data.list;
  62. console.log('asd:' + JSON.stringify(this.tab));
  63. this.tab.forEach(item => {
  64. item.locationSet = JSON.parse(item.locationSet);
  65. });
  66. this.refresh();
  67. }
  68. });
  69. },
  70. //刷新数据
  71. refresh() {
  72. //this.item = this.tab[this.current];
  73. this.item.lat=this.tab[0].lat;
  74. this.item.lng=this.tab[0].lng;
  75. this.tab.forEach(item => {
  76. if (item.shapeType == 'polyline') {
  77. item.locationSet.forEach(l => {
  78. this.polyline[0].points.push({ latitude: l.lat, longitude: l.lng });
  79. });
  80. }
  81. if (item.shapeType == 'polygon') {
  82. item.locationSet.forEach(l => {
  83. this.polygon[0].points.push({ latitude: l.lat, longitude: l.lng });
  84. });
  85. }
  86. if (item.shapeType == 'circle') {
  87. this.circles[0].latitude = this.item.locationSet.lat;
  88. this.circles[0].longitude = this.item.locationSet.lng;
  89. this.circles[0].radius = this.item.radius;
  90. }
  91. if (item.shapeType == 'marker') {
  92. let iconPictures = '';
  93. if (item.iconPictures != null && item.iconPictures != '') {
  94. iconPictures = this.$http.urls.ip + item.iconPictures;
  95. }
  96. item.locationSet.forEach(l => {
  97. this.markers.push({
  98. latitude: l.lat,
  99. longitude: l.lng,
  100. iconPath: iconPictures,
  101. callout: {
  102. display: 'ALWAYS',
  103. content: item.markerName,
  104. padding: 7,
  105. bgColor: '#4CAF50',
  106. borderRadius: 5,
  107. color: '#ffffff'
  108. }
  109. });
  110. });
  111. }
  112. });
  113. }
  114. }
  115. };
  116. </script>
  117. <style lang="scss">
  118. .map {
  119. position: fixed;
  120. width: 100%;
  121. height: 100%;
  122. }
  123. </style>