位置请求超时

时间:2019-02-05 10:34:48

标签: react-native geolocation

我想获取设备的当前位置,并将其获取到我们办公室内。但是当我按下“签到”按钮时,它总是会提示一条消息

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 }
    );

};

1 个答案:

答案 0 :(得分:0)

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

来解决
相关问题