1***@qq.com
1***@qq.com
  • 发布:2023-03-23 17:51
  • 更新:2023-03-23 20:16
  • 阅读:184

如何解决连续获取uni.getLocation延迟问题

分类:uni-app

在使用原生插件的情况下可以每秒获取一次安卓的定位,
但是在使用官方提供的uni.getLocation的时候,轮询操作无法每秒获取安卓定位信息,会出现获取位置失败的情况

let time = setInterval(function() {  
                // _Location.getLocation(res => {  
                //  console.log(res);  
                //  _this.publish(res.longitude, res.latitude, 0);  
                // });  
                uni.getLocation({  
                    type: 'wgs84 ',  
                    geocode:true,  
                    success: function(res) {  
                        console.log(res)  
                        // uni.setStorageSync('userLocation', JSON.stringify(res));  
                    },  
                    fail: function() {  
                        uni.showToast({  
                            title: '获取位置失败',  
                            icon: 'none'  
                        });  
                    }  
                });  
            }, 1000);
2023-03-23 17:51 负责人:无 分享
已邀请:
亦春亦秋

亦春亦秋 - 用爱发电

别获取那么频繁

  • 1***@qq.com (作者)

    APP需要每秒上报一次定位,需求这样没办法~~

    2023-03-24 08:22

要回复问题请先登录注册