map_page.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <view class="body2">
  3. <u-navbar :autoBack="true" title="地图" bgColor="rgba(255,255,255,0)" :placeholder="true" titleStyle="font-weight:bold;color:#121212"></u-navbar>
  4. <map
  5. id="map"
  6. :enable-rotate="true"
  7. :enable-3D="true"
  8. :latitude="latitude"
  9. :longitude="longitude"
  10. :markers="marker"
  11. :scale="scale"
  12. @markertap="markertap"
  13. style="width: 100%; height: 100%"
  14. ></map>
  15. </view>
  16. </template>
  17. <script>
  18. let that;
  19. export default {
  20. data() {
  21. return {
  22. isLoading: false, // 节流阀 默认为关闭状态
  23. main_body_id: '',
  24. model_id: '',
  25. marker: [],
  26. latitude: 24.511709899939145, //纬度
  27. longitude: 118.14707269879153, //经度
  28. scale: 13 //缩放级别,
  29. };
  30. },
  31. onLoad(o) {
  32. that = this;
  33. this.main_body_id = this.$db.get('main_body_id');
  34. // this.model_id = o.id;
  35. this.ditu();
  36. },
  37. methods: {
  38. ditu(id) {
  39. this.$api.getContentList(
  40. {
  41. model_id: '1',
  42. main_body_id: '1',
  43. page: 1,
  44. pageSize: '12'
  45. },
  46. function (res) {
  47. that.marker = [];
  48. res.data.forEach((item, index) => {
  49. // console.log(item, 'itemitem');
  50. that.latitude = item.latitude;
  51. that.longitude = item.longitude;
  52. that.marker.push({
  53. id: parseFloat(item.id),
  54. latitude: parseFloat(item.latitude), //纬度
  55. longitude: parseFloat(item.longitude), //经度
  56. iconPath: '/static/image/icon_map.png', //显示的图标
  57. width: 35, //宽
  58. height: 35, //高
  59. joinCluster: true,
  60. title: item.title, //标注点名
  61. label: {
  62. //自定义标记点上方的文本
  63. content: item.title, //文本
  64. color: '#5c3c2e', //文字颜色
  65. fontSize: 20, //文本大小
  66. bgColor: 'rgba(0,0,0,.2)', // 背景颜色(半透明黑色)
  67. borderRadius: 10, // 边框圆角
  68. padding: [2, 2], // 内边距
  69. textAlign: 'center', // 文本对齐方式
  70. display: 'ALWAYS' // 始终显示标签
  71. }
  72. });
  73. });
  74. }
  75. );
  76. },
  77. // 点击标记点时触发
  78. markertap(e) {
  79. console.log(e);
  80. uni.navigateTo({
  81. url: `/index_fenbao/jianzhu/jianZhuXQ?id=${e.target.markerId}`
  82. });
  83. },
  84. // 建筑详情
  85. buildBtn(i) {
  86. uni.navigateTo({
  87. url: this.jianZhuList[i].page
  88. });
  89. }
  90. }
  91. };
  92. </script>
  93. <style>
  94. .body2 {
  95. width: 100%;
  96. height: 100%;
  97. }
  98. .banxin {
  99. margin: 0 32rpx 0 32rpx;
  100. }
  101. </style>