是不是直接调用wx.openLocation,不会弹出授权框啊,我试了三个手机都没弹,为啥官方文档里说需要授权呢-灵析社区

万码007

小程序前段时间好像更新了,现在调用类似的接口都需要先主动邀请用户授权,小程序不会主动拉起授权了现在,你先使用wx.getSetting,在成功的时候再调用openLocation试试在你的地图地图图标外面加一层button<button open-type="openSetting" bindtap="onGotSetting">打开授权设置页</button>然后在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) { //你的操作 }) } }) }) } } }) }

阅读量:1

点赞量:0

问AI