1.在https://lbs.qq.com/console/mykey.html?console=mykey連接上申請一個密匙html
2.在https://lbs.qq.com/qqmap_wx_jssdk/index.html下載微信小程序JavaScriptSDKgit
3.在頁面引入文件var QQMapWX = require("../../../static/qqmap-wx-jssdk.min.js");小程序
4.var that = this;微信小程序
let qqmapsdk = new QQMapWX({
key: "****" // 密匙
});
wx.getLocation({
type: "gcj02",
success(res) {
//騰訊地圖逆地址解析
qqmapsdk.reverseGeocoder({
location: {
latitude: res.latitude,
longitude: res.longitude
},
success(addressRes) {
that.address = addressRes.result.formatted_addresses.recommend; //獲取地理位置名字
}
});
}
});