is it true that calling wx.openLocation, directly won"t pop up the authorization box? I tried three phones but didn"t play. Why does the official document say that authorization is needed?
is it true that calling wx.openLocation, directly won"t pop up the authorization box? I tried three phones but didn"t play. Why does the official document say that authorization is needed?
Mini Program seems to have updated some time ago. Now to call similar interfaces, you need to actively invite users to authorize. Mini Program will not take the initiative to pull the authorization. Now, first use wx.getSetting, and then call openLocation when successful.
add a layer of button
< button open-type= "openSetting" bindtap= "onGotSetting" to your map icon. Open the authorization settings page < / button >
and then write
onGotSetting:function(){
wx.getSetting({
success(res) {
if (!res.authSetting['scope.userLocation']) {
wx.authorize({
scope: 'scope.userLocation',
success() {
wx.getLocation({
type: 'gcj02', //wx.openLocation
success: function(res) {
//
})
}
})
})
}
}
})
}
first use getSetting to check whether the user is authorized. If not, hang the authorization window. Now there is usually a button
.wx.getSetting({
success(res) {
if (!res.authSetting['scope.userLocation']) {
wx.authorize({
scope: 'scope.userLocation',
success(res) {
}
})
}
}
})
Previous: Laydate date plug-in, how to call the "clear" event with JS
Next: Does vscode have a file watchers function similar to webstorm?
I use wx.openLocation to adjust the map directly. The green button in the lower right corner of the iPhone allows me to choose the route, but there is no route option on Android. Why? ...
I read the official document that this API has been adjusted, and there will be no authorization pop-up window using this API. Please use < button open-type= "getUserInfo " > < button > to guide the user to take the initiative to authorize the operati...
what my Mini Program needs is to help the backend get the unionid to get through the official account and Mini Program. I get the login status and maintain the login. ...
for example, when my md5 encryption js is placed in the utils folder, and the js of the page needs to be introduced into md5, what is the difference between using require introduction and import introduction? I think the official document says to use req...