Possible fix to gps crash

This commit is contained in:
Keannu Bernasol 2023-07-19 22:21:19 +08:00
parent 98bd8dcfb8
commit 60f2250cb8

View file

@ -4,7 +4,7 @@ import { useSelector } from "react-redux";
import { RootState } from "../../features/redux/Store/Store";
import AnimatedContainer from "../../components/AnimatedContainer/AnimatedContainer";
import { useState, useEffect } from "react";
import MapView, { Marker, UrlTile } from "react-native-maps";
import MapView, { Animated as AnimatedMap } from "react-native-maps";
import * as Location from "expo-location";
import GetDistance from "../../components/GetDistance/GetDistance";
import Button from "../../components/Button/Button";
@ -33,17 +33,25 @@ export default function Home() {
return;
}
if (status == "granted") {
try {
let location = await Location.getCurrentPositionAsync({});
if (location) {
setLocation(location);
getDistance(location);
}
} catch (error) {
setFeedback("Error: " + error);
}
}
}, 2000);
}
useEffect(() => {
const interval = setInterval(() => {
requestLocation();
}, [location]);
}, 1000);
return () => clearInterval(interval);
});
useEffect(() => {
requestLocation();
}, []);
@ -81,7 +89,7 @@ export default function Home() {
You are too far from USTP {"\n"}
Get closer to use Stud-E
</Text>
<MapView
<AnimatedMap
style={{
height: Viewport.height * 0.5,
width: Viewport.width * 0.8,