微信小程序的获取当前位置--步骤
第一步:前往微信公众平台开通权限:
第二步:微信小程序中app.json 开通权限:
"permission": {"scope.userLocation": {"desc": "你的位置信息将用于展示当前位置"}},"requiredPrivateInfos": ["getLocation"],
第三步:编辑代码:
wx.getLocation({type: 'gcj02',success: (res) => {console.log(res.longitude)console.log(res.latitude)},fail: () => {wx.showToast({title: '无法获取位置wx.getLocation',icon: 'none'});}});