顺晟科技
2021-06-16 10:49:33
265
注意,使用这个功能之前手机得先打开位置信息。
现在app.json配置
{
第' :页[
页面/地图/地图,
页面/索引/索引,
页面/寄存器/寄存器,
'页面/日志/日志'
],
window': {
背景文本样式' : '灯,
导航工具栏颜色' : ' # fff ',
navigationBarTitleText ' : '微信,
navigationBarTextStyle': '黑色'
},
权限' : {
范围。UserLocationbackground ' : {
desc': '位置信息将用于展示所在地区'
}
},
requiredBackgroundModes ' :[' location '],
站点地图位置' : '站点地图。JSON '
}
页面射流研究…代码
getUserLocation() {
wx.getSetting({
成功(res) {
console.log(res)
if(RES . AuthSetting['作用域。UserLocationbackground ']){
wx。startlocationupdatebackground({
success: (res)={
控制台。日志(' startLocationUpdate-res ',res)
},
fail: (err)={
控制台。日志(' startLocationUpdate-err ',err)
}
})
} else {
if(RES . AuthSetting['作用域。UserLocation ']==false){
console.log('打开设置页面去授权)
} else {
wx。startlocationupdatebackground({
success: (res)={
控制台。日志(' startLocationUpdate-res ',res)
},
fail: (err)={
控制台。日志(' startLocationUpdate-err ',err)
}
})
}
}
}
})
},
然后在昂秀监听用户实时位置信息
昂秀(){
这个。getuser location();
const _locationChangeFn=res={
console.log('位置变更,res.latitude,res .经度)
}
wx。onlocationchange(_ locationChangeFn);
16
2021-06
16
2021-06
16
2021-06
16
2021-06
16
2021-06
16
2021-06