//wxml
<button type="default" bindtap="openMap">打開地圖</button>
//js
Page({
data: {
},
openMap: function () {
wx.getLocation({
type: 'gcj02', // 默認(rèn)為 wgs84 返回 gps 坐標(biāo),gcj02 返回可用于 wx.openLocation 的坐標(biāo)
success: function (res) {
// success
console.log(res.latitude);
console.log(res.longitude);
wx.openLocation({
latitude: res.latitude, // 緯度,范圍為-90~90,負(fù)數(shù)表示南緯
longitude: res.longitude, // 經(jīng)度,范圍為-180~180,負(fù)數(shù)表示西經(jīng)
scale: 28, // 縮放比例
name:"要找的地方名字(某某飯店)",
address:"地址:要去的地點詳細(xì)描述"
})
}
})
}
})
效果

image.png
點擊按鈕后效果

image.png
官方API地址:https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.openLocation.html