You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
react-native : The term 'react-native' is not recognized
as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a
path was included, verify that the path is correct and
try again.
At line:1 char:1
This code in one of my applications works smoothly. On rendering the screen it shows my currentpositon in the intial region. However this doesn't work for my other applications, I wonder why? This is the error it shows
. Please I would need a code that would allow me show my current location, immediately the my screen renders. Note: I am developping for Android.
Reproducible Demo
The text was updated successfully, but these errors were encountered:
Environment
react-native : The term 'react-native' is not recognized
as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a
path was included, verify that the path is correct and
try again.
At line:1 char:1
Platforms
Android
Versions
Description
`import { View, useWindowDimensions, PermissionsAndroid, Platform, Pressable, ActivityIndicator } from 'react-native'
import React, {useState, useEffect} from 'react'
import Geolocation from '@react-native-community/geolocation';
import MapView, {PROVIDER_GOOGLE, Marker} from 'react-native-maps';
const GOOGLE_MAPS_APIKEY = '*';
const HomeScreen = () => {
const {width, height}= useWindowDimensions()
const [myPosition, setMyPosition] = useState(null)
useEffect(() => {
const requestLocationPermission = async () => {
if (Platform.OS === 'android') {
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
{
title: 'Atua Location Request',
message: 'Atua needs access to your location.',
buttonNeutral: 'Ask Me Later',
buttonNegative: 'Cancel',
buttonPositive: 'OK',
},
);
if (granted === PermissionsAndroid.RESULTS.DENIED) {
console.log('Location permission denied');
return;
}
}
}, []);
return (
<MapView
style={{width, height:height-150}}
provider={PROVIDER_GOOGLE}
showsUserLocation
initialRegion={{
latitude: myPosition.latitude,
longitude: myPosition.longitude ,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
}}
>
<Marker
title={'hi'}
description={'Good'}
coordinate={{
latitude:37.43199,
longitude:-122.099
}}/>
)
}
export default HomeScreen`
This code in one of my applications works smoothly. On rendering the screen it shows my currentpositon in the intial region. However this doesn't work for my other applications, I wonder why? This is the error it shows
. Please I would need a code that would allow me show my current location, immediately the my screen renders. Note: I am developping for Android.
Reproducible Demo
The text was updated successfully, but these errors were encountered: