js:
onLoad: function () {
// 获取位置
var that = this;
// 实例化腾讯地图API核心类
qqmapsdk = new QQMapWX({
key: 'PKYBZ-EB4RQ-KBF5P-GMINL-C6FXK-FHBNI' // 必填
});
wx.getLocation({
type: 'wgs84',
success: function (res) {
that.setData({
latitude:res.latitude,
longitude:res.longitude
})
//2、根据坐标获取当前位置名称,显示在顶部:腾讯地图逆地址解析
qqmapsdk.reverseGeocoder({
location: {
latitude: res.latitude,
longitude: res.longitude
},
success: function (e) {
var location = e.result.address;
console.log("add="+location)
(为什么这一段不会打印)
that.setData({
location: location
})
}
})
// console.log("res==" + app.globalData.latitude)
// console.log("res==" + app.globalData.longitude)
that.setData({
ldata: true,
// latitude: latitude,
// longitude: longitude
})
},
fail: function (res) {
console.log('拒绝授权')
that.setData({
ldata: false
})
}
})
},
btnTap(e) {
console.log("e+" + this.data.latitude + "," + this.data.longitude)
wx.openLocation({
latitude: this.data.latitude,
longitude: this.data.longitude,
scale: 50
})
},
wxml:
微信小程序开发问题解答
微信小程序开发者回答:

还是这样
微信小程序开发者回答:
能否来个大佬看看呢,不知道咋办呀
本文网址:http://www.91bianli.com/kaifazhinan/75056.html