当前位置:网站首页>微信小程序获取住户地区信息
微信小程序获取住户地区信息
2022-07-05 09:21:00 【.translucent】
微信小程序获取住户地区信息
微信小程序获取住户地区信息
1.现在app.js里面配置如下
{
//向用户申请获取授权
"permission": {
"scope.userLocation": {
"desc": "你的位置信息将用于小程序位置接口的效果展示"
}
}
}
2.在所需要获取的地区调用微信api
wx.getLocation({
type: 'wgs84',
success (res) {
const latitude = res.latitude
const longitude = res.longitude
const speed = res.speed
const accuracy = res.accuracy
}
})
//res返回如下字段
{
accuracy: 65;
errMsg: "getLocation:ok";
horizontalAccuracy: 65;
latitude: 30.25961; // 纬度,范围为 -90~90,负数表示南纬
longitude: 120.13026; // 经度,范围为 -180~180,负数表示西经
speed: -1;
verticalAccuracy: 65;
}
3.通过获取用户的api来获取用户的地址
//获取用户的ip地址
const getposition = () =>{
const params = {
//请求地址来获取用户ip
url:'https://pv.sohu.com/cityjson?ie=utf-8'
}
return request(params)
}
//getipconfig
//调用请求
const res = await getposition()
const m = JSON.parse(res.data.match(/.*(\{[^\}]+\}).*/)[1] || '{}')
//获取到ip
console.log('ip =>', m.cip, m)
通过IP地址来查询所用用户的地址
get请求http://ip-api.com/json/ip
http://ip-api.com/json/36.143.40.237
边栏推荐
- [beauty of algebra] solution method of linear equations ax=0
- Talking about label smoothing technology
- Newton iterative method (solving nonlinear equations)
- Alibaba cloud sends SMS verification code
- Transfer learning and domain adaptation
- Blue Bridge Cup provincial match simulation question 9 (MST)
- Add discount recharge and discount shadow ticket plug-ins to the resource realization applet
- 基于STM32单片机的测温仪(带人脸检测)
- fs. Path module
- Codeworks round 681 (Div. 2) supplement
猜你喜欢

Svg optimization by svgo

Figure neural network + comparative learning, where to go next?

OpenGL - Model Loading

信息與熵,你想知道的都在這裏了

22-07-04 西安 尚好房-项目经验总结(01)

【组队 PK 赛】本周任务已开启 | 答题挑战,夯实商品详情知识

L'information et l'entropie, tout ce que vous voulez savoir est ici.

Shutter uses overlay to realize global pop-up

AUTOSAR from getting started to mastering 100 lectures (103) -dbc file format and creation details

C form click event did not respond
随机推荐
测试老鸟浅谈unittest和pytest的区别
Kotlin introductory notes (III) kotlin program logic control (if, when)
Introduction Guide to stereo vision (5): dual camera calibration [no more collection, I charge ~]
Progressive JPEG pictures and related
[ctfhub] Title cookie:hello guest only admin can get flag. (cookie spoofing, authentication, forgery)
Uni app implements global variables
Nodejs modularization
L'information et l'entropie, tout ce que vous voulez savoir est ici.
Codeforces Round #648 (Div. 2) E.Maximum Subsequence Value
Codeforces Round #648 (Div. 2) D. Solve The Maze
Android 隐私沙盒开发者预览版 3: 隐私安全和个性化体验全都要
np. allclose
. Net service governance flow limiting middleware -fireflysoft RateLimit
[reading notes] Figure comparative learning gnn+cl
Creation and reference of applet
Talking about label smoothing technology
Generate confrontation network
Mengxin summary of LCs (longest identical subsequence) topics
Codeforces round 684 (Div. 2) e - green shopping (line segment tree)
深入浅出PyTorch中的nn.CrossEntropyLoss