加油站付款小程序,打印小票
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.

94 lines
1.8 KiB

9 months ago
  1. <template>
  2. <view class="content">
  3. <map style="width: 100%; height: 90vh;"
  4. :layer-style='5'
  5. :style="{height:mapheight}"
  6. :show-location='true'
  7. :latitude="latitude"
  8. :longitude="longitude"
  9. :markers="markers"
  10. :scale="scale"
  11. @markertap="markertap"
  12. @callouttap='callouttap'>
  13. <!-- subkey="66c5a2ad2849" -->
  14. </map>
  15. </view>
  16. </template>
  17. <script>
  18. import position from '@/utils/position.js'
  19. export default {
  20. data() {
  21. return {
  22. latitude: 23.106574, //纬度
  23. longitude: 113.324587, //经度
  24. scale: 10, //缩放级别
  25. bottomData: false,
  26. mapCtx: null,
  27. markers:[
  28. { //标记点A 的信息
  29. iconPath: "/static/logo.png", //图标
  30. id: 0,
  31. width: 20, //图标icon 宽度
  32. height: 28 ,//图标icon 高度
  33. latitude: 26.1272,
  34. longitude: 113.11659
  35. }
  36. ]
  37. }
  38. },
  39. onLoad() {
  40. position.getLocation(res => {
  41. console.log(res);
  42. this.latitude = res.latitude
  43. this.longitude = res.longitude
  44. })
  45. },
  46. computed: {
  47. mapheight() {
  48. let data = ''
  49. if (this.bottomData) {
  50. if (this.upTop) {
  51. data = '50px'
  52. } else {
  53. data = '200px'
  54. }
  55. } else {
  56. data = '90vh'
  57. }
  58. return data
  59. },
  60. coverbottom() {
  61. let data = ''
  62. if (this.bottomData) {
  63. data = '20rpx'
  64. } else {
  65. data = '100rpx'
  66. }
  67. return data
  68. }
  69. },
  70. onShow() {
  71. this.mapCtx = wx.createMapContext('map');
  72. this.mapCtx && this.mapCtx.addCustomLayer({
  73. layerId: '66c5a2ad2849',
  74. success: (res) => {
  75. console.log('success', res);
  76. },
  77. fail: (e) => {
  78. console.log('fail', e);
  79. },
  80. });
  81. },
  82. methods: {
  83. //地图点击事件
  84. markertap(e) {
  85. console.log("===你点击了标记点===", e)
  86. },
  87. //地图点击事件
  88. callouttap(e) {
  89. console.log('地图点击事件', e)
  90. }
  91. }
  92. }
  93. </script>