收藏
回答

关于持续定位?

在我使用小程序中的持续定位功能时。

我延迟加载设置了1分钟定位一次。前面几次都定位成功了,有返回XY坐标。但是经过6-7次以后定位就全部返回坐标为0 这是什么原因导致的。。我是做的真机调试。。开发版

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

2 个回答

  • 黄开琴
    黄开琴
    发表于移动端
    2021-05-21
    、一下士贝卡宀下七具下一贝八卡、下七只下坝卢5/下专、彭水下坝店紫为一星
    2021-05-21
    有用
    回复
  • 灵芝
    灵芝
    2020-05-21

    你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

    2020-05-21
    有用
    回复 10
    • 颜文斌
      颜文斌
      2020-05-21
      Page({
        data: {
          motto: '正在获取用户定位信息',
          userInfo: {},
          hasUserInfo: false,
          time: 1,
          level:'',
          networkType:'',
          canIUse: wx.canIUse('button.open-type.getUserInfo'),
          insertLocation: "/HyApi/hylocation/insertLocation",
        },
        //事件处理函数
        bindViewTap: function() {
          wx.navigateTo({
            url: '../logs/logs'
          })
        },
        onLoad: function () {
          let that = this;
          wx.getBatteryInfo({
            success(res) {
              that.setData({
                level:res.level
              })
              console.log('电量:',res.level)
              console.log('是否正在充电:', res.isCharging)
            }
          })
          wx.getNetworkType({
            success: function (res) {
              that.setData({
                networkType:res.networkType
              })
              console.log(res)
            }
          })
          this.locationWz();
        },
        locationWz(){
          let that = this;
          let num = 1;
          wx.startLocationUpdateBackground({
            success(res) {
            console.log('开启后台定位', res)
            wx.onLocationChange(function(res) {
              if(num==1){
              console.log('定位回调', res)
              util.getNoLoad(that.data.insertLocation, { latitude: res.latitude,longitude: res.longitude,openId:wx.getStorageSync("openId"),networkStatus:that.data.networkType,electricQuantity:that.data.level}, function (res) {
                console.log("aaa:" + res.data);
              })
              if(res.latitude!=undefined){
                wx.stopLocationUpdate(function(res) {
                  console.log('停止定位', res)
                })
                that.setTime();
              }
            }
            num= 0;
            })
            },
            fail(res) {
            console.log('开启后台定位失败', res)
            }
            })
        },
        setTime(){
          let that = this
          wx.stopLocationUpdate();
            setTimeout(function () {
              wx.getLocation({
                type: 'wgs84',
                success (res) {
                  console.log("wgs84:",res)
                  const latitude = res.latitude
                  const longitude = res.longitude
                  const speed = res.speed
                  const accuracy = res.accuracy
                }
               })
              that.locationWz()
            }, 600000) //延迟时间 这里是1分
        },
      })
      2020-05-21
      回复
    • 颜文斌
      颜文斌
      2020-05-21
      是用小米手机
      2020-05-21
      回复
    • 颜文斌
      颜文斌
      2020-05-21
      https://developers.weixin.qq.com/s/5xK1vvmW76hN
      2020-05-21
      回复
    • 灵芝
      灵芝
      2020-05-21回复颜文斌
      这边未复现问题,请复现问题后提供日志:我->设置->帮助与反馈右上角有个上报日志的入口
      提供出现问题的微信号,出现问题的时间点(精确到分钟)
      2020-05-21
      回复
    • 颜文斌
      颜文斌
      2020-05-22
      日志没报异常错误 就是返回的坐标都是0而已
      2020-05-22
      回复
    查看更多(5)
登录 后发表内容
问题标签