当前位置:网站首页>Wechat applet obtains household area information
Wechat applet obtains household area information
2022-07-05 09:24:00 【. translucent】
Wechat applet obtains household area information
Wechat applet obtains household area information
1. Now? app.js The configuration is as follows
{
// Apply to the user for authorization
"permission": {
"scope.userLocation": {
"desc": " Your location information will be used to show the effect of the applet location interface "
}
}
}
2. Call wechat in the area you need to get api
wx.getLocation({
type: 'wgs84',
success (res) {
const latitude = res.latitude
const longitude = res.longitude
const speed = res.speed
const accuracy = res.accuracy
}
})
//res Return the following fields
{
accuracy: 65;
errMsg: "getLocation:ok";
horizontalAccuracy: 65;
latitude: 30.25961; // latitude , The scope is -90~90, A negative number means south latitude
longitude: 120.13026; // longitude , The scope is -180~180, A negative number means the west longitude
speed: -1;
verticalAccuracy: 65;
}
3. By getting the user's api To get the user's address
// Get the user's ip Address
const getposition = () =>{
const params = {
// Request the address to get the user ip
url:'https://pv.sohu.com/cityjson?ie=utf-8'
}
return request(params)
}
//getipconfig
// Call request
const res = await getposition()
const m = JSON.parse(res.data.match(/.*(\{[^\}]+\}).*/)[1] || '{}')
// Get ip
console.log('ip =>', m.cip, m)
adopt IP Address to query the address of the user used
get request http://ip-api.com/json/ip
http://ip-api.com/json/36.143.40.237
边栏推荐
- Applet (subcontracting)
- Progressive JPEG pictures and related
- Kotlin introductory notes (VII) data class and singleton class
- C # image difference comparison: image subtraction (pointer method, high speed)
- Return of missing persons
- [beauty of algebra] solution method of linear equations ax=0
- np. allclose
- LeetCode 503. 下一个更大元素 II
- 混淆矩阵(Confusion Matrix)
- Kotlin introductory notes (I) kotlin variables and non variables
猜你喜欢
Huber Loss
Applet (use of NPM package)
Introduction Guide to stereo vision (3): Zhang calibration method of camera calibration [ultra detailed and worthy of collection]
OpenGL - Coordinate Systems
[code practice] [stereo matching series] Classic ad census: (5) scan line optimization
信息与熵,你想知道的都在这里了
[ctfhub] Title cookie:hello guest only admin can get flag. (cookie spoofing, authentication, forgery)
Applet (global data sharing)
Using request headers to develop multi terminal applications
Svg optimization by svgo
随机推荐
Rebuild my 3D world [open source] [serialization-1]
Talking about label smoothing technology
Confusion matrix
Kotlin introductory notes (V) classes and objects, inheritance, constructors
一题多解,ASP.NET Core应用启动初始化的N种方案[上篇]
[reading notes] Figure comparative learning gnn+cl
STM32 simple multi-level menu (array table lookup method)
Android 隐私沙盒开发者预览版 3: 隐私安全和个性化体验全都要
信息與熵,你想知道的都在這裏了
Progressive JPEG pictures and related
Can't find the activitymainbinding class? The pit I stepped on when I just learned databinding
Return of missing persons
牛顿迭代法(解非线性方程)
L'information et l'entropie, tout ce que vous voulez savoir est ici.
[beauty of algebra] solution method of linear equations ax=0
Rebuild my 3D world [open source] [serialization-3] [comparison between colmap and openmvg]
My life
Talking about the difference between unittest and pytest
Codeworks round 638 (Div. 2) cute new problem solution
Editor use of VI and VIM