我在寻找位置时遇到了一个小问题,这是我的代码
export default class App extends React.Component{
state = {
location: null
};
findCoordinates = () => {
Geolocation.getCurrentPosition(
position => {
const location = JSON.stringify(position);
this.setState({ location });
},
error => Alert.alert(error.message),
{ enableHighAccuracy: true, timeout: 15000, maximumAge: 10000 }
);
};
render(){
return (
<View style={styles.container}>
<TouchableOpacity onPress={this.findCoordinates}>
<Text style={styles.welcome}>Find My Coords?</Text>
<Text>Location: {this.state.location}</Text>
</TouchableOpacity>
</View>
);
}
}
Run Code Online (Sandbox Code Playgroud)
他们显示未授予位置许可