React Native geo-location在离线模式下工作吗?我正在我的设备上测试,geolocation.watchPosition工作得很好,但当我切换到飞行模式时,我得到了一个位置错误。我打开我的谷歌地图应用程序,可以看到位置仍然在那里跟踪(在飞机模式下)。如何让react native中的地理位置在脱机模式下工作?如果不可能,还有什么替代方案呢?
注意:我正在IOS上测试,但正在寻找一个可以在Android和IOS上工作的解决方案。
谢谢。
发布于 2017-10-30 09:34:58
我已经尝试过我的工作,但并不总是它取决于你的信号,即使你不连接到互联网它也取决于你的设备接收信号在我的情况下,我正在使用华硕zenfone 6进行测试当我连接到互联网时,它工作得很好,但在其他情况下,当我没有连接到互联网时,它工作得很好,但在其他情况下,我使用三星s7进行测试,当我连接到互联网时,它工作得非常好,但当我没有连接到互联网时,它有时工作(工作最多/比华硕zenfone 6更多),但不是很好的准确性
希望这能回答你的问题,如果有人对我如何在没有互联网的情况下修复不好的准确性有什么建议,请留下评论
发布于 2017-08-31 13:54:33
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />中提供位置权限
class GeoLoc extends React.Component{
constructor(props){
super(props);
this.state = {
latitude: null,
longitude: null,
error: null,
};
}
componentDidMount(){
navigator.geolocation.getCurrentPosition( (position)=>{
//const ipos = JSON.stringify(Position);
this.setState({
latitude: position.coords.latitude,
longitude: position.coords.longitude,
error: null,
});
},
(error) => this.setState({ error: error.message }),
{ enableHighAccuracy: true, timeout: 20000, maximumAge: 1000 }
);
}
render(){
return(
<View>
<Text>Latitude: {this.state.latitude}</Text>
<Text>Longitude: {this.state.longitude}</Text>
<Text> {this.state.error} </Text>
</View>
)
}}
https://stackoverflow.com/questions/44489011
复制相似问题