8.微信小程序地图使用 微信小程序

shuke 2017-12-6 1620

微信小程序地图使用

在使用微信小程序定位经纬度来定位所在的位置在注意以下几点:

一,要使用微信获取地址的方法:getLocation

var that = this
    wx.getLocation({
      type: "wgs84",
      success: function (res) {
        console.log(res)
        that.setData({
          map: {
            Latitude: res.latitude,
            Longitude: res.longitude
          }
        })
      },
    })

二,在模板中写入地图代码

<map id='map1'  scale='{{18}}' latitude='{{map.Latitude}}' longitude='{{map.Longitude}}'></map>

scale 是缩放级别 官方是有5到18个级别;个人测试实际是3到18个级别,数字越大,代表地图区域越精确。

latitude 代表纬度

longitude  代表经度



三,图片效果

最新回复 (0)
全部楼主
返回