Map View With Pin Point Accuracy in React Native & Expo Apps

Google Maps For Android & iOS Apps

Google Map in react native & expo apps

Project setup, Package Requirements, and Code

npx expo install expo-location
npx expo install react-native-maps
const [mapRegion, setMapRegion] = useState({
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
});
const userLocation = async () => {
let {status} = await Location.requestForegroundPermissionsAsync();
if (status !== 'granted') {
setErrorMsg('Permission to access location was denied');
}
let location = await Location.getCurrentPositionAsync({enableHighAccuracy: true});
setMapRegion({
latitude: location.coords.latitude,
longitude: location.coords.longitude,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
});
console.log(location.coords.latitude, location.coords.longitude);
}
useEffect(() => {
userLocation();
}, []);

Why do I suggest watching more videos?

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store