|
@@ -567,19 +567,23 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- let currentLocation = await Location.getCurrentPositionAsync({
|
|
|
- accuracy: Location.Accuracy.Balanced
|
|
|
- });
|
|
|
- setLocation(currentLocation.coords);
|
|
|
-
|
|
|
- if (showNomads && token) {
|
|
|
- updateLocation({
|
|
|
- token,
|
|
|
- lat: currentLocation.coords.latitude,
|
|
|
- lng: currentLocation.coords.longitude
|
|
|
+ try {
|
|
|
+ let currentLocation = await Location.getCurrentPositionAsync({
|
|
|
+ accuracy: Location.Accuracy.Balanced
|
|
|
});
|
|
|
+ setLocation(currentLocation.coords);
|
|
|
|
|
|
- refetchUsersLocation();
|
|
|
+ if (showNomads && token) {
|
|
|
+ updateLocation({
|
|
|
+ token,
|
|
|
+ lat: currentLocation.coords.latitude,
|
|
|
+ lng: currentLocation.coords.longitude
|
|
|
+ });
|
|
|
+
|
|
|
+ refetchUsersLocation();
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('Error fetching user location:', error);
|
|
|
}
|
|
|
})();
|
|
|
}, [locationSettings]);
|
|
@@ -819,29 +823,33 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
};
|
|
|
|
|
|
const getLocation = async () => {
|
|
|
- let currentLocation = await Location.getCurrentPositionAsync({
|
|
|
- accuracy: Location.Accuracy.Balanced
|
|
|
- });
|
|
|
- setLocation(currentLocation.coords);
|
|
|
+ try {
|
|
|
+ let currentLocation = await Location.getCurrentPositionAsync({
|
|
|
+ accuracy: Location.Accuracy.Balanced
|
|
|
+ });
|
|
|
+ setLocation(currentLocation.coords);
|
|
|
|
|
|
- if (currentLocation.coords) {
|
|
|
- cameraRef.current?.flyTo(
|
|
|
- [currentLocation.coords.longitude, currentLocation.coords.latitude],
|
|
|
- 1000
|
|
|
- );
|
|
|
- }
|
|
|
+ if (currentLocation.coords) {
|
|
|
+ cameraRef.current?.flyTo(
|
|
|
+ [currentLocation.coords.longitude, currentLocation.coords.latitude],
|
|
|
+ 1000
|
|
|
+ );
|
|
|
+ }
|
|
|
|
|
|
- if (showNomads && token) {
|
|
|
- updateLocation({
|
|
|
- token,
|
|
|
- lat: currentLocation.coords.latitude,
|
|
|
- lng: currentLocation.coords.longitude
|
|
|
- });
|
|
|
+ if (showNomads && token) {
|
|
|
+ updateLocation({
|
|
|
+ token,
|
|
|
+ lat: currentLocation.coords.latitude,
|
|
|
+ lng: currentLocation.coords.longitude
|
|
|
+ });
|
|
|
|
|
|
- refetchUsersLocation();
|
|
|
- }
|
|
|
+ refetchUsersLocation();
|
|
|
+ }
|
|
|
|
|
|
- handleClosePopup();
|
|
|
+ handleClosePopup();
|
|
|
+ } catch (error) {
|
|
|
+ console.error('Error fetching user location:', error);
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
const handleAcceptPermission = async () => {
|