业务需求需要将经纬度解析为详细地址,去年使用的是百度地图,今年发现腾旭地图也更新了微信小程序的地图的接口;
1. http://lbs.qq.com/guides/startup.html
申请腾讯地图的key
;
这里需要注意:
记得勾选微信小程序并填写正确的appid
;其他的空着即可
2. 使用方法
文档地址http://lbs.qq.com/qqmap_wx_jssdk/index.html
使用方法
const QQMapWX = require('../../libs/qqmap-wx-jssdk.min.js');
const wxMap = new QQMapWX({
key: '****-GP***-RB***-B**US-****-RZ**Y'
});
onShow () {
/**经纬度逆解析 */
this.reverseGeocoder()
},
/**经纬度逆解析 */
reverseGeocoder() {
const that = this;
wx.getLocation({
type: 'gcj02',
success: function (res) {
var latitude = res.latitude
var longitude = res.longitude
wxMap.reverseGeocoder({
location: {
latitude: latitude,
longitude: longitude
},
success: function (res) {
const { city } = res.result.address_component
console.log(city);
that.setData({
city,
})
},
});
},
fail(res) {
console.log(res)
}
})
},
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)