微信小程序 腾讯地图(小白适用)
微信小程序中一般有的定位导航的功能,这是后就需要腾讯的地图了(百度地图不行的呢),怎么在一个页面简单又高效的使用地图呢,
思路其实相当简单
第一步:在页面上放个图片,当时然是地图的,这就需要设计小姐姐帮忙了,
第二步:给图片添加点击事件 (bindtap='locationtap')
<view class='m_t20' bindtap='locationtap'>
<image style='width:95%;border-radius:10px;' src='{{img3}}'></image>
<text class='ellipsis c_theme font_weight'>{{shopInfo.address}}</text>
</view>
第三步:在js中添加点击事件,用来触发腾讯地图
//点击触发腾讯地图
locationtap: function (e) {
var that = this;
wx.getLocation({
type: 'gcj02', //返回可以用于wx.openLocation的经纬度
success(res) {
const latitude = res.latitude //纬度
const longitude = res.longitude //经度
//这是你选中的地址
wx.openLocation({
latitude: 34.240155,
longitude: 108.899749,
name: '西安限公司',
address: '西安市橙仕空间'
})
}
})
},