WeChat applet obtains location, locates monitoring

wx.startLocationUpdateBackground(Object object) | WeChat Open Documentation WeChat Developer Platform Documentation https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.startLocationUpdateBackground.htmlWeChat Mini Program JavaScript SDK | Tencent Location Service Tencent Maps Open Platform provides various application manufacturers and developers with geolocation services and solutions based on Tencent Maps; there are JavaScript APIs for web applications, various SDKs for native apps on mobile phones, WebService interfaces and various map APIs, etc. . https://lbs.qq.com/miniProgram/jsSdk/jsSdkGuide/jsSdkOverview

First, the wx.startLocationUpdate method starts the reception of the foreground location. Use the wx.startLocationUpdateBackground method to obtain the user address in the background;

wx.startLocationUpdate({
    success: res => {
        console.log(res);
	},
    fail: err => {}
})

wx.onLocationChange(_locationChangeFn) Pass a method, the method receives parameters including longitude, latitude, precision and other information.
 Then use the reverse address parsing reverseGeocoder() method in the WeChat applet JavaScriptSDK to convert the latitude and longitude into regional text;

The download location of qqmap-wx-jssdk.min.js is in the above document;

var QQMap = require('../../js_sdk/qqmap-wx-jssdk.min.js')
var qqmapsdk = new QQMap({
	key: '自己的key' // 必填
});



qqmapsdk.reverseGeocoder({
							location: {
								//纬度
								latitude: res.latitude,
								//经度
								longitude: res.longitude
							},
							success: function(res) {
								console.log(res.result);
							fail: function(err) {
								console.log(err);
							}
						})

When the official launch, you need to add the request legal domain name

https://apis.map.qq.com

Guess you like

Origin blog.csdn.net/qq_18676843/article/details/121580462