Is it true that directly calling wx.openLocation, will not pop up the authorization box? I tried three mobile phones but did not 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

in page.
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) {
              }
            })
          }
      }
    })
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea8ae6-1ef2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea8ae6-1ef2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?