微信小程序地图map的markers属性polyline属性controls属性全解析教程

第一:JS页面

// pages/about/about.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    markers: [{ 
      iconPath: '../../images/logo.jpg',
      id: 0,
      latitude: 34.780254,
      longitude: 113.699559,
      width: 30,
      height: 30,
      title:"【软银科技】\n网络营销领导者,让公司业绩倍增\n倍增热线:15136135201",
      callout:{
        content:"【软银科技】\n网络营销领导者,让公司业绩倍增\n倍增热线:15136135201",
        color:"#2c8df6",
        fontSize:20,
        borderRadius:10,
        bgColor:"#fff",
        display:"ALWAYS",
        boxShadow:"2px 2px 10px #aaa"
        }, 
      label: {
        color: "#000",
        fontSize: 12, 
        content: "为标记点旁边增加标签",
        x: 34.780439,
        y: 113.699774
      }
    }],
    polyline: [{
      points: [{
        latitude: 34.780254,
        longitude: 113.699559
        
      }, {
          longitude: 113.701855,
        latitude: 34.779778
      }],
      color: "#ff6600",
      width: 2,
      dottedLine: false,
      arrowLine: true,
      borderColor:"#000",
      borderWidth:5
    }],
    controls: [{
      id: 1,
      iconPath: '../../images/icon_cate.png',
      position: {
        left: 0,
        top: 300 - 50,
        width: 50,
        height: 50
      },
      clickable: true
    }]
  },
  regionchange(e) {
    console.log(e.type)
  },
  markertap(e) {
    console.log(e.markerId)
  },
  controltap(e) {
    console.log(e.controlId)
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  
  },
  //拨打手机号码
  makePhoneCall: function () {
    var that = this
    wx.makePhoneCall({
      phoneNumber: '15136135201',
      success: function () {
        console.log("成功拨打电话")
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})

第二:wxml页面

<!--pages/about/about.wxml-->

 <map id="map" longitude="113.699559" latitude="34.780254" scale="14" controls="{{controls}}" bindcontroltap="controltap" markers="{{markers}}" bindmarkertap="markertap" polyline="{{polyline}}" bindregiοnchange="regionchange" show-location style="width: 100%; height: 300px;"></map>

<button type="primary" bindtap="makePhoneCall">拨打</button>
 
<button open-type="contact">进入客服会话</button>

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值