1、主要运用到wx.getLocation和wx.chooseLocation,想要个性化或不需要地图,只显示周边可以使用腾讯地图官方文档提供的开放性接口,动态显示周边地址。
data: {
my_latitude:"",
my_longitude:"",
chooseAddress:"",
},
//以当前位置为中心打开腾讯地图
chooseAddressFn(){
let that=this
wx.chooseLocation({
latitude: that.data.latitude,
longitude: that.data.longitude,
success(e){
console.log(e)
that.setData({
chooseAddress:e.address+e.name, ////具体详细信息需另外填写(门牌号等)
my_latitude: e.latitude,
my_longitude: e.longitude,
});
}
})
},
//获取当前位置信息,获得lat,lng国测局坐标系
getMyLocation(){
wx.getLocation({
type: 'gcj02',
isHighAccuracy:true,//高精度
success (res) {
that.setData({
my_latitude:res.latitude,
my_longitude:res.longitude
})
const speed = res.speed
const accuracy = res.accuracy
qqmapsdk = new QQMapWX({
key: '腾讯地

本文介绍如何利用微信小程序的位置服务API实现当前位置获取、周边地点搜索及距离计算等功能,并提供了详细的代码示例。
最低0.47元/天 解锁文章
9617

被折叠的 条评论
为什么被折叠?



