小程序
小游戏
企业微信
微信支付
扫描小程序码分享
我想拿到当前定位经纬度和地址描述
除了经纬度还需要 xxx路xx号 或者 xxx小区南门 或者xxx地铁站
怎么拿到详细信息呢?只能服务端用api解析吗?
4 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
用腾讯地图的逆地址解析
https://https://lbs.qq.com/miniProgram/jsSdk/jsSdkGuide/methodReverseGeocoder
使用案例:
var QQMapWX = require('../../static/js/qqmap-wx-jssdk.min'); var qqmapsdk; Page({ onLoad: function () { // 实例化API核心类 qqmapsdk = new QQMapWX({ key: '申请的key' }); }, onShow: function () { let that = this wx.getLocation({ type: "gcj02", success(res) { that.reverseGeocoder(res.latitude,res.longitude) }, fail(err) { console.log(11111111); wx.hideLoading(); wx.showToast({ title: '定位失败', icon: 'none', duration: 1500 }) self.setData({ lastPage: false, isRefreshing: false }) } }) }, reverseGeocoder(lat, lng) { let that = this qqmapsdk.reverseGeocoder({ location: { latitude: lat, longitude: lng }, success: function (res) { //成功后的回调 console.log('reverseGeocoder:', res); that.setData({ }) }, fail: function (error) { console.error(error); }, complete: function (res) { console.log(res); } }) }, })
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
是的,只能通过拿到的经纬度进行逆地址解析
只能获取经纬度,想要位置信息,只有你自己通过腾讯api等转换
本回答由AI生成,可能已过期、失效或不适用于当前情形,请谨慎参考
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
用腾讯地图的逆地址解析
https://https://lbs.qq.com/miniProgram/jsSdk/jsSdkGuide/methodReverseGeocoder
使用案例:
var QQMapWX = require('../../static/js/qqmap-wx-jssdk.min'); var qqmapsdk; Page({ onLoad: function () { // 实例化API核心类 qqmapsdk = new QQMapWX({ key: '申请的key' }); }, onShow: function () { let that = this wx.getLocation({ type: "gcj02", success(res) { that.reverseGeocoder(res.latitude,res.longitude) }, fail(err) { console.log(11111111); wx.hideLoading(); wx.showToast({ title: '定位失败', icon: 'none', duration: 1500 }) self.setData({ lastPage: false, isRefreshing: false }) } }) }, reverseGeocoder(lat, lng) { let that = this qqmapsdk.reverseGeocoder({ location: { latitude: lat, longitude: lng }, success: function (res) { //成功后的回调 console.log('reverseGeocoder:', res); that.setData({ }) }, fail: function (error) { console.error(error); }, complete: function (res) { console.log(res); } }) }, })
是的,只能通过拿到的经纬度进行逆地址解析
只能获取经纬度,想要位置信息,只有你自己通过腾讯api等转换