收藏
回答

小程序getLocation无法拉起授权窗口?

const longitude = 123;

    const latitude = 12;

    wx.getSetting({

      success(res) {

        if (!res.authSetting['scope.userLocation']) {

           var that = this

          wx.openSetting({

            success (res) {

              if(res.authSetting["scope.userLocation"]) {

                wx.getLocation({

                  type: 'wgs84', // gcj02返回可以用于wx.openLocation的经纬度

                  success: function (res) {

                    wx.openLocation({ //​使用微信内置地图查看位置。

                      longitude: longitude, //要去的经度-地址

                      latitude: latitude, //要去的纬度-地址

                      // name: that.data.companyInfo.locusname,//地名

                      // address: that.data.companyInfo.address //简介

                    })

                  }

                })

              }else {

                wx.showToast({

                  title: '请授权',

                })

              }

            }

          })

        } else {

          wx.getLocation({

            type: 'wgs84', // gcj02返回可以用于wx.openLocation的经纬度

            success: function (res) {

              wx.openLocation({ //​使用微信内置地图查看位置。

                longitude: longitude, //要去的经度-地址

                latitude: latitude, //要去的纬度-地址

                // name: that.data.companyInfo.locusname,//地名

                // address: that.data.companyInfo.address //简介

              })

            }

          })

        }

      }

    })


回答关注问题邀请回答
收藏

2 个回答

  • Cjiang
    Cjiang
    2020-12-17

    请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

    2020-12-17
    有用
    回复
  • 强子
    强子
    2020-12-17

    app.json文件已添加以下代码也失效

    "permission": {
        "scope.userLocation": {
          "desc""你的位置信息将用于小程序位置接口的效果展示"
        }
      }
    


    2020-12-17
    有用
    回复
登录 后发表内容
问题标签