|
@@ -313,7 +313,9 @@ const MapScreen: React.FC<MapScreenProps> = ({ navigation, route }) => {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- let currentLocation = await Location.getCurrentPositionAsync({});
|
|
|
+ let currentLocation = await Location.getCurrentPositionAsync({
|
|
|
+ accuracy: Location.Accuracy.Low
|
|
|
+ });
|
|
|
setLocation(currentLocation.coords);
|
|
|
})();
|
|
|
}, []);
|
|
@@ -394,15 +396,17 @@ const MapScreen: React.FC<MapScreenProps> = ({ navigation, route }) => {
|
|
|
});
|
|
|
setLocation(currentLocation.coords);
|
|
|
|
|
|
- mapRef.current?.animateToRegion(
|
|
|
- {
|
|
|
- latitude: currentLocation.coords.latitude,
|
|
|
- longitude: currentLocation.coords.longitude,
|
|
|
- latitudeDelta: 5,
|
|
|
- longitudeDelta: 5
|
|
|
- },
|
|
|
- 800
|
|
|
- );
|
|
|
+ currentLocation.coords?.latitude &&
|
|
|
+ currentLocation.coords?.longitude &&
|
|
|
+ mapRef.current?.animateToRegion(
|
|
|
+ {
|
|
|
+ latitude: currentLocation.coords.latitude,
|
|
|
+ longitude: currentLocation.coords.longitude,
|
|
|
+ latitudeDelta: 5,
|
|
|
+ longitudeDelta: 5
|
|
|
+ },
|
|
|
+ 800
|
|
|
+ );
|
|
|
|
|
|
handleClosePopup();
|
|
|
};
|
|
@@ -426,7 +430,11 @@ const MapScreen: React.FC<MapScreenProps> = ({ navigation, route }) => {
|
|
|
const handleMapPress = async (event: {
|
|
|
nativeEvent: { coordinate: { latitude: any; longitude: any }; action?: string };
|
|
|
}) => {
|
|
|
- if (event.nativeEvent?.action === 'marker-press') return;
|
|
|
+ if (
|
|
|
+ event.nativeEvent?.action === 'marker-press' ||
|
|
|
+ event.nativeEvent?.action === 'callout-inside-press'
|
|
|
+ )
|
|
|
+ return;
|
|
|
|
|
|
cancelTokenRef.current = true;
|
|
|
const { latitude, longitude } = event.nativeEvent.coordinate;
|
|
@@ -436,10 +444,10 @@ const MapScreen: React.FC<MapScreenProps> = ({ navigation, route }) => {
|
|
|
let tableName = 'places';
|
|
|
let foundRegion: any;
|
|
|
|
|
|
- type !== 1 && (foundRegion = findRegionInDataset(dareData, point));
|
|
|
+ type !== 1 && (foundRegion = dareData ? findRegionInDataset(dareData, point) : null);
|
|
|
|
|
|
if (type === 1) {
|
|
|
- foundRegion = findRegionInDataset(regions, point);
|
|
|
+ foundRegion = regions ? findRegionInDataset(regions, point) : null;
|
|
|
db = getFirstDatabase();
|
|
|
tableName = 'regions';
|
|
|
|
|
@@ -486,7 +494,7 @@ const MapScreen: React.FC<MapScreenProps> = ({ navigation, route }) => {
|
|
|
}
|
|
|
|
|
|
if (!foundRegion) {
|
|
|
- foundRegion = findRegionInDataset(regions, point);
|
|
|
+ foundRegion = regions ? findRegionInDataset(regions, point) : null;
|
|
|
db = getFirstDatabase();
|
|
|
tableName = 'regions';
|
|
|
}
|
|
@@ -605,7 +613,9 @@ const MapScreen: React.FC<MapScreenProps> = ({ navigation, route }) => {
|
|
|
}
|
|
|
|
|
|
const dataset = type === 'regions' ? regions : dareData;
|
|
|
- const foundRegion = dataset.features.find((region: any) => region.properties.id === id);
|
|
|
+ const foundRegion = dataset
|
|
|
+ ? dataset.features.find((region: any) => region.properties.id === id)
|
|
|
+ : null;
|
|
|
|
|
|
if (foundRegion) {
|
|
|
setSelectedRegion({
|