MapContainer.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <view>
  3. <map style="width: 100%; height: 469rpx" :latitude="latitude" :longitude="longitude" scale="18" :markers="markers" :polyline="polyline" enable-3D></map>
  4. </view>
  5. </template>
  6. <script setup>
  7. import { ref } from 'vue'
  8. import { onLoad } from '@dcloudio/uni-app'
  9. // 中心点
  10. const latitude = ref(28.103487)
  11. const longitude = ref(114.443029)
  12. // 图标点数据
  13. const markers = ref([
  14. {
  15. iconPath: '/static/images/marker.png',
  16. id: 1,
  17. latitude: 28.705019,
  18. longitude: 115.831653,
  19. width: 18,
  20. height: 18,
  21. callout: {
  22. content: '10:50\n进入校园',
  23. fontSize: 12,
  24. borderRadius: 6,
  25. padding: 6,
  26. display: 'ALWAYS',
  27. textAlign: 'left',
  28. anchorX: 30
  29. }
  30. },
  31. {
  32. iconPath: '/static/images/marker.png',
  33. id: 2,
  34. latitude: 28.704551,
  35. longitude: 115.831675,
  36. width: 18,
  37. height: 18,
  38. callout: {
  39. content: '11:50\n吃饭',
  40. fontSize: 12,
  41. borderRadius: 6,
  42. padding: 6,
  43. display: 'ALWAYS',
  44. textAlign: 'left',
  45. anchorX: 30
  46. }
  47. },
  48. {
  49. iconPath: '/static/images/marker.png',
  50. id: 3,
  51. latitude: 28.704951,
  52. longitude: 115.832297,
  53. width: 18,
  54. height: 18,
  55. callout: {
  56. content: '12:50\n睡觉',
  57. fontSize: 12,
  58. borderRadius: 6,
  59. padding: 6,
  60. display: 'ALWAYS',
  61. textAlign: 'left',
  62. anchorX: 30
  63. }
  64. }
  65. ])
  66. // 地图轨迹数据
  67. const polyline = ref([
  68. {
  69. points: [
  70. { latitude: 28.705019, longitude: 115.831653 },
  71. { latitude: 28.704551, longitude: 115.831675 },
  72. { latitude: 28.704951, longitude: 115.832297 }
  73. ],
  74. color: '#1E7DFB',
  75. width: 2
  76. }
  77. ])
  78. onLoad(() => {})
  79. </script>
  80. <style scoped></style>