景徳镇旅游微信小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

135 lines
2.7 KiB

8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
  1. <template>
  2. <view class="page">
  3. <map
  4. style="width: 100%;"
  5. :layer-style='5'
  6. :style="{height:mapheight}"
  7. :show-location='true'
  8. :latitude="latitude"
  9. :longitude="longitude"
  10. :markers="markers"
  11. :scale="scale"
  12. @markertap="markertap"
  13. @callouttap='callouttap'>
  14. </map>
  15. <view class="content">
  16. <locations/>
  17. </view>
  18. <tabber select="1"/>
  19. </view>
  20. </template>
  21. <script>
  22. import position from '@/utils/position.js'
  23. import locations from '@/components/tourGuide/locations.vue'
  24. export default {
  25. components : {
  26. locations,
  27. },
  28. data() {
  29. return {
  30. latitude: 23.106574, //纬度
  31. longitude: 113.324587, //经度
  32. scale: 12, //缩放级别
  33. bottomData: false,
  34. mapCtx: null,
  35. markers:[
  36. // { //标记点A 的信息
  37. // iconPath: "/static/logo.png", //图标
  38. // id: 0,
  39. // width: 20, //图标icon 宽度
  40. // height: 28 ,//图标icon 高度
  41. // latitude: 26.1272,
  42. // longitude: 113.11659
  43. // }
  44. ],
  45. }
  46. },
  47. onLoad() {
  48. position.getLocation(res => {
  49. console.log(res);
  50. this.latitude = res.latitude
  51. this.longitude = res.longitude
  52. this.random()
  53. })
  54. },
  55. computed: {
  56. mapheight() {
  57. let data = ''
  58. if (this.bottomData) {
  59. if (this.upTop) {
  60. data = '50px'
  61. } else {
  62. data = '200px'
  63. }
  64. } else {
  65. data = '50vh'
  66. }
  67. return data
  68. },
  69. coverbottom() {
  70. let data = ''
  71. if (this.bottomData) {
  72. data = '20rpx'
  73. } else {
  74. data = '100rpx'
  75. }
  76. return data
  77. }
  78. },
  79. onShow() {
  80. // this.mapCtx = wx.createMapContext('map');
  81. // this.mapCtx && this.mapCtx.addCustomLayer({
  82. // layerId: '66c5a2ad2849',
  83. // success: (res) => {
  84. // console.log('success', res);
  85. // },
  86. // fail: (e) => {
  87. // console.log('fail', e);
  88. // },
  89. // });
  90. },
  91. methods: {
  92. //地图点击事件
  93. markertap(e) {
  94. console.log("===你点击了标记点===", e)
  95. this.markers.forEach(n => {
  96. if(n.id == e.detail.markerId){
  97. uni.openLocation({
  98. latitude: n.latitude,
  99. longitude: n.longitude,
  100. })
  101. }
  102. })
  103. },
  104. //地图点击事件
  105. callouttap(e) {
  106. console.log('地图点击事件', e)
  107. },
  108. random(){
  109. let list = []
  110. for(let i = 0;i < 10;i++){
  111. let a = uni.$uv.random(1, 4)
  112. let obj = {
  113. latitude: this.latitude + uni.$uv.random(1, 30) / 1000 * (uni.$uv.random(1, 3) - 2),
  114. longitude: this.longitude + uni.$uv.random(1, 30) / 1000 * (uni.$uv.random(1, 3) - 2),
  115. width: 20, //图标icon 宽度
  116. height: 28 ,//图标icon 高度
  117. iconPath: `/static/image/tourGuide/${a}.png`, //图标
  118. id: i,
  119. }
  120. list.push(obj)
  121. }
  122. this.markers = list
  123. },
  124. }
  125. }
  126. </script>
  127. <style scoped lang="scss">
  128. .page{
  129. }
  130. </style>