地图页面添加按钮控件

新建文件夹img,右键单击硬盘打开,然后将所需要的素材图片保存进去。
在data里面新加控件属性controls,此处的controls为数组。
然后在onload的里面加载controls,

 that.setData({
     contros:[{
       id:1,
       iconPath:'/img/sao.jpg',
       position:{
         width:100,
         height:60,
         left:100,
         top:400
       }
     }]
   })

iconPath:是背景图片地址
position:控件在地图中的相对于的位置
记着在index.wxml中加载
controls='{{contros}}'

image.png

获取设备信息

查看小程序开发文档,API里面有个设备,可以获取设备信息。
wx.getSystemInfo
返回值情况

image.png

在onload里面修改

wx.getSystemInfo({
     success: function(res) {
       var windowWidth=res.windowWidth;
       var windowHeight=res.windowHeight;
       that.setData({
         contros: [{
           id: 1,
           iconPath: '/img/sao.png',
           position: {
             width: 100,
             height: 80,
             left: windowWidth / 2-50,
             top: windowHeight-100
           },
           clickable:true
         },
         {
           id:2,
           iconPath:'/img/pay.png',
           position:{
             width:30,
             height:40,
             left:windowWidth-40,
             top:windowHeight-100
           },
           clickable:true
         },
           {
             id: 3,
             iconPath: '/img/baoxiu.png',
             position: {
               width: 30,
               height: 30,
               left: windowWidth - 40,
               top: windowHeight - 50
             },
             clickable: true
           },
           {
             id: 4,
             iconPath: '/img/定位.png',
             position: {
               width: 30,
               height: 30,
               right: windowWidth - 40,
               top: windowHeight - 80
             },
             clickable: true
           }
         ]
       })
     },
   })
   

这里面添加了四个控件,包括支付,报修和返回原定位地址


image.png

clickable是控件可点击,因为后期还需要进行相应的操作

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,778评论 25 709
  • 1、通过CocoaPods安装项目名称项目信息 AFNetworking网络请求组件 FMDB本地数据库组件 SD...
    阳明AI阅读 16,020评论 3 119
  • 大家好,我是廖天鹏,今天我拆解的片段来自于书籍《关键对话》【学习目标】 在跟随我完成本次RIA现场学习后,大家能够...
    廖天鹏阅读 263评论 0 0
  • 早些年当看到大街上摇曳着不同高度高跟鞋的女人优雅着、仪态万方的从我身边走过,我都眼羡的不得了。羡慕之余也...
    李晓茹阅读 685评论 0 2
  • 孩子昨晚不知道几点睡的,直到12点多还不起来,看时间确实不早了,平静的喊孩子起来,孩子也没有很抗拒,起来坐床上看手...
    心想事就成阅读 142评论 0 0