收藏
回答

安卓的wx.getLocation总是失败呢

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug wx.getLocation 客户端 7.0.0 Android 8.1.0 WeChat 7.0.1380

对于安卓系列的 手机 wx.Location( {   } )   一直不执行。   调试时 已经确保手机 获取位置 开关 是打开状态。


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

8 个回答

  • Tummy
    Tummy
    2019-01-18

    非常感谢反馈,给大家带来了麻烦,抱歉。
    我们尽快修复,估摸着最快也是下个星期了..


    本质原因是当小程序页面为map时调getLocation,map showLocation属性冲掉了getLocation的回调
    这里可以先1.showlocation置为true,等getLocation回来再置为false 2.getLocation fail后再次调用.


    2019-01-18
    有用
    回复 1
    • 丷丷
      丷丷
      2019-07-26
      我页面不为map,我在app.js里面调getLocation,app.json里面permission也配置了,在开发工具上调用没问题,ios也没问题,安卓一进去直接fail
      2019-07-26
      1
      回复
  • 禾店短剧系统
    禾店短剧系统
    2021-05-26

    日常道歉🤦‍♂️🤦‍♂️🤦‍♂️

    2021-05-26
    有用 1
    回复
  • null
    null
    2019-12-20

    (已解决)如果getLocation函数在安卓上调用的时候一直走到fail可以尝试调用两次getLocation函数

    wx.getLocation
              ({
                type: 'gcj02',
                success(res) {
                  console.log(res);
                  that.data.latitude = res.latitude
                  that.data.longitude = res.longitude
                }
              })
            wx.getLocation({
              type: 'wgs84 ',
              success(res) {
                that.data.latitude = res.latitude
                that.data.longitude = res.longitude
                console.log("更新latitude:" + that.data.latitude);
                console.log("更新longitude:" + that.data.longitude);
              },
              fail: function () {
                wx.showToast
                  ({
                    title: "获取位置信息失败,请稍后再试",
                    icon: 'none',
                    duration: 2000
                  })
              }
            })
    
    2019-12-20
    有用
    回复
  • 旅行者
    旅行者
    2019-01-18

    安卓手机只有在小程序第一次加载的时候才会主动弹窗地理位置授权,如果用户点击拒绝之后,以后都不会再主动弹窗提醒用户地理位置授权了。对于拒绝授权再次进入的情况,可以使用官方提供的button组件模拟授权弹窗,open-type="openSetting"可以打开授权。


    2019-01-18
    有用
    回复 6
    • PeiPei
      PeiPei
      2019-01-19

      这个 有尝试 了 但是 并没有用。

      2019-01-19
      回复
    • 姜龙
      姜龙
      2019-02-28回复PeiPei

      这个问题解决了吗

      2019-02-28
      回复
    • PeiPei
      PeiPei
      2019-03-01回复姜龙

      解决了  

      2019-03-01
      回复
    • PeiPei
      PeiPei
      2019-03-01回复姜龙

      官方给的 解决方案

      2019-03-01
      回复
    • 姜龙
      姜龙
      2019-03-01

      好的 谢谢你

      2019-03-01
      回复
    查看更多(1)
  • 旺仔小星星!
    旺仔小星星!
    2019-01-18

    同上只有安卓机会有这个问题,是在开发版本出现的问题, wx.Location( ),只在第一次加载界面的时候是生效的,但是为了调取接口数据,需要打开调试,点击打开调试时,自动退出小程序,在次进入的时候有的时候就不会调用wx.Location(),导致我们需要获取当前位置的数据取不到。   

    2019-01-18
    有用
    回复
  • ゆスケ
    ゆスケ
    2019-01-16

    是的 但是ios是正常的 在线观望 前排刘明

    2019-01-16
    有用
    回复
  • 是我的粥
    是我的粥
    2019-01-16

    我也碰到这个问题 就是安卓机调wx.getlocation 不执行

    2019-01-16
    有用
    回复
  • 灵芝
    灵芝
    2019-01-16

    具体报错信息是什么呢?

    2019-01-16
    有用
    回复 24
    • PeiPei
      PeiPei
      2019-01-16

      没有报错啊   就是这个 wx.getLocatiion()   安卓机器 不执行 。

      2019-01-16
      回复
    • 灵芝
      灵芝
      2019-01-16回复PeiPei

      不执行?也没有超时提醒吗?给个代码片段测试一下

      2019-01-16
      回复
    • PeiPei
      PeiPei
      2019-01-16回复灵芝

      onShow: function () {

      this.setData({

      isPhoneX: app.globalData.isPhoneX,

      GGList:[],

      newList:[],

      num: '>',

      HCcount:'>',

      HZship:'>',

      markers: [{

      iconPath: '/img/index/pos.png',

      id: 0,

      latitude: '',

      longitude: '',

      width: 16,

      height: 19

      }]

      })

      this.getBanner();

      this.getGonggao();

      this.getXTGonggao();

      this.getNewList();

      if (wx.getStorageSync('loginStatus')) this.getNum(wx.getStorageSync('uid'))

      if (wx.getStorageSync('loginStatus')) this.getHCCount(wx.getStorageSync('uid'));

      if (wx.getStorageSync('loginStatus')) this.getHZship(wx.getStorageSync('uid'));

      let that = this

      wx.getLocation({

      type: 'gcj02',

      success: (res) => {

      console.log(res, 'res')

      that.setData({

      longitude: app.globalData.lng,

      latitude: app.globalData.lat,

      })

      that.data.markers[0].longitude = app.globalData.lng,

      that.data.markers[0].latitude = app.globalData.lat,


      that.setData({

      markers: that.data.markers

      })


      this.getShip(res.longitude, res.latitude);

      },

      fail: function (fail) {

      console.log(fail)

      }


      })

      },


      2019-01-16
      回复
    • 灵芝
      灵芝
      2019-01-17回复PeiPei

      是这个格式的代码片段哈(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

      2019-01-17
      回复
    • Feebas丶
      Feebas丶
      2019-01-17回复灵芝

      我今天试了也是,在工具上试了可以用,但是在手机上测试就不行,代码片段就不上了,随便调用wx.getLocation({})就不执行,直接走了fail(){},麻烦你们测试一下看看,是不是你们那边的问题

      2019-01-17
      回复
    查看更多(19)
登录 后发表内容