route.vue 2.8 KB

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