//wxml<button type="default" bindtap="openMap">打开地图</button>
//jsPage({ data: { }, openMap: function () { wx.getLocation({ type: 'gcj02', // 默认为 wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标 success: function (res) { // success console.log(res.latitude); console.log(res.longitude); wx.openLocation({ latitude: res.latitude, // 纬度,范围为-90~90,负数表示南纬 longitude: res.longitude, // 经度,范围为-180~180,负数表示西经 scale: 28, // 缩放比例 name:"要找的地方名字(某某饭店)", address:"地址:要去的地点详细描述" }) } }) } })
效果
image.png
点击按钮后效果
image.png
官方API地址:https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.openLocation.html
作者:前端来入坑
链接:https://www.jianshu.com/p/464aa3d0e251
點(diǎn)擊查看更多內(nèi)容
為 TA 點(diǎn)贊
評(píng)論
評(píng)論
共同學(xué)習(xí),寫下你的評(píng)論
評(píng)論加載中...
作者其他優(yōu)質(zhì)文章
正在加載中
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說(shuō)多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦