location.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <view>
  3. <cu-custom :bgColor="NavBarColor" :isBack="true">
  4. <block slot="backText">返回</block>
  5. <block slot="content">定位</block>
  6. </cu-custom>
  7. <map style="width: 100%; height:500px;" :latitude="latitude" :longitude="longitude" :markers="marker"
  8. :scale="scale">
  9. </map>
  10. </view>
  11. </template>
  12. <script>
  13. export default {
  14. data() {
  15. return {
  16. NavBarColor: this.NavBarColor,
  17. id: 0, // 使用 marker点击事件 需要填写id
  18. title: 'map',
  19. latitude: 40.009704, //纬度
  20. longitude: 116.374999, //经度
  21. marker: [{
  22. id: 0,
  23. latitude: 40.009704, //纬度
  24. longitude: 116.374999, //经度
  25. iconPath: '/static/location.png', //显示的图标
  26. rotate: 0, // 旋转度数
  27. width: 20, //宽
  28. height: 20, //高
  29. title: '你在哪了', //标注点名
  30. alpha: 0.5, //透明度
  31. callout: { //自定义标记点上方的气泡窗口 点击有效
  32. content: '北京国炬公司', //文本
  33. color: '#ffffff', //文字颜色
  34. fontSize: 14, //文本大小
  35. bordius: 2, //边框圆角
  36. bgColor: '#00c16f', //背景颜色
  37. display: 'ALWAYS' //常显
  38. }
  39. }],
  40. scale: 16, //地图缩放程度
  41. controls: [{ //在地图上显示控件,控件不随着地图移动
  42. id: 1, //控件id
  43. iconPath: '/static/login3.png', //显示的图标
  44. clickable: true,
  45. position: { //控件在地图的位置
  46. left: 15,
  47. top: 15,
  48. width: 50,
  49. height: 50
  50. },
  51. }],
  52. circles: [{ //在地图上显示圆
  53. latitude: 40.009704,
  54. longitude: 116.374999,
  55. radius: 50, //半径
  56. fillColor: "#ffffffAA", //填充颜色
  57. color: "#55aaffAA", //描边的颜色
  58. strokeWidth: 1 //描边的宽度
  59. }],
  60. }
  61. },
  62. onLoad() {
  63. this.getLocation()
  64. },
  65. methods: {
  66. getLocation() {
  67. uni.getLocation({
  68. type: 'gcj02',
  69. success: function(res) {},
  70. fail: function(res) {
  71. }
  72. });
  73. }
  74. }
  75. }
  76. </script>
  77. <style>
  78. </style>