啷个
啷个
  • 发布:2023-04-27 10:40
  • 更新:2023-05-05 11:09
  • 阅读:502

uniapp H5端 使用 uni.onLocationChange 只在初始化更新了一次就不再更新位置信息。

分类:uni-app

uniapp H5端 使用 uni.onLocationChange 只在初始化更新了一次就不再更新位置信息。

uni.startLocationUpdate({  
              success: res => {  
                  uni.onLocationChange(function(res) {  
                    _this.latitude = res.latitude;  
                    _this.longitude = res.longitude;  
                    _this.center[0] = res.longitude;  
                    _this.center[1] = res.latitude;  
                    console.log('纬度:' + res.latitude);  
                    console.log('经度:' + res.longitude);  
                  });  
              },  
              fail: err => console.error('开启小程序接收位置消息失败:', err),  
              complete: msg => console.log('调用开启小程序接收位置消息 API 完成')  
            });
2023-04-27 10:40 负责人:DCloud_UNI_WZF 分享
已邀请:
啷个

啷个 (作者)

有没有遇到的小伙伴

  • DCloud_UNI_WZF

    设备移动一段距离是否更新

    2023-05-06 17:13

  • 啷个 (作者)

    回复 DCloud_UNI_WZF: 移动可能数十米才会更新,但是如果关闭屏幕再打开就立即更新了

    2023-05-06 17:25

  • DCloud_UNI_WZF

    回复 啷个: navigator.geolocation.watchPosition 能力如此,如果需要更精细的控制,可能需要看看地图服务商是否有对应服务或者自己做心跳检测

    2023-05-06 18:27

要回复问题请先登录注册