Also, the const { status } = await Permissions.getAsync(Permissions.LOCATION); call is returning “undetermined” for me and it does not ask me to grant the LOCATION permission. You should call askAsync like in the example from the documentation:
async function getLocationAsync() {
// permissions returns only for location permissions on iOS and under certain conditions, see Permissions.LOCATION
const { status, permissions } = await Permissions.askAsync(Permissions.LOCATION);
if (status === 'granted') {
return Location.getCurrentPositionAsync({ enableHighAccuracy: true });
} else {
throw new Error('Location permission not granted');
}
}
yes i am . n even if you remove this line still the code is not working the poblem is in the _getlocation method may be . but i think i have written it correctly
now also this is not working in my snack . i am not gettting any location plz see my code also
import * as React from 'react';
import { Text, View, StyleSheet } from 'react-native';
import * as Expo from 'expo';
import MapView ,{PROVIDER_GOOGLE} from 'react-native-maps'
import {Permissions , Location } from 'expo';
export default class App extends React.Component {
state = {
location: null
}
_getLocation = async() => {
console.log("console is coming .............let s see how are you")
const {status ,permission } = await Permissions.getAsync(Permissions.LOCATION)
console.log("let see this line of code")
if(status !== 'granted'){
console.error('why this console is not coming ......................')
return console.error('why this console is not coming ......................')
}
let location = await Location.getCurrentPositionAsync({})
this.setState({ location })
console.log("nor the console.log of this location.......")
return console.log(location)
}
componentDidMount() {
this._getLocation()
}
render() {
if(!this.state.location){
return (<Text> hello it will not work </Text>)
}
return (
<MapView style={{flex: 1}}
initialRegion={{
latitude: this.state.location.coords.latitude,
longitude: this.state.location.coords.longitude,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}}
/>
);
}
}