【问题标题】:Location request timed out位置请求超时
【发布时间】:2019-02-05 10:34:47
【问题描述】:

我想获取我的设备的当前位置,并且我正在我们的办公室内获取它。但是当我按下签入按钮时,它总是会提示一条消息

findCoordinates = () => {
    navigator.geolocation.getCurrentPosition(
        position => {
            // const location = JSON.stringify(position);
            console.log("LOCATION", position.coords.longitude, position.coords.latitude);
            this.setState({
                latitude: position.coords.latitude,
                longitude: position.coords.longitude,
            });
            this.props.onCheckin(this.state.latitude, this.state.longitude, this.props.employee_id);
        },
        error => Alert.alert(error.message),
        // { enableHighAccuracy: true, timeout: 20000, maximumAge: 1000 }
        { enableHighAccuracy: true, timeout: 5000, maximumAge: 10000 }
    );

};

【问题讨论】:

  • 我只是按照代码 sn-p 来获取当前位置,这就是原因。
  • 还是同样的问题“位置请求超时”。实际上我在办公室里,有没有其他方法可以做到这一点??

标签: react-native geolocation


【解决方案1】:

这是特定版本的android的问题,可以通过删除enableHighAccuracy: true来解决

【讨论】:

    猜你喜欢
    • 2017-04-28
    • 1970-01-01
    • 2011-02-26
    • 2017-06-20
    • 2013-05-12
    • 2011-04-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多