|
@@ -13,7 +13,7 @@ import LocationIcon from '../../../../assets/icons/location.svg';
|
|
|
import CloseSvg from '../../../../assets/icons/close.svg';
|
|
|
|
|
|
import regions from '../../../../assets/geojson/nm2022.json';
|
|
|
-import dareRegions from '../../../../assets/geojson/mqp.json';
|
|
|
+import jsonData, { fetchJsonData } from '../../../database/geojsonService';
|
|
|
|
|
|
import { getFirstDatabase, getSecondDatabase, refreshDatabases } from '../../../db';
|
|
|
import { LocationPopup, WarningModal, EditNmModal } from '../../../components';
|
|
@@ -50,6 +50,7 @@ const localDareDir = `${FileSystem.cacheDirectory}tiles/regions_mqp`;
|
|
|
const AnimatedMarker = Animated.createAnimatedComponent(Marker);
|
|
|
|
|
|
const MapScreen: React.FC<MapScreenProps> = ({ navigation }) => {
|
|
|
+ const [dareData, setDareData] = useState(jsonData);
|
|
|
const tilesBaseURL = `${FASTEST_MAP_HOST}/tiles_osm`;
|
|
|
const gridUrl = `${FASTEST_MAP_HOST}/tiles_nm/grid`;
|
|
|
const dareTiles = `${FASTEST_MAP_HOST}/tiles_nm/regions_mqp`;
|
|
@@ -91,6 +92,17 @@ const MapScreen: React.FC<MapScreenProps> = ({ navigation }) => {
|
|
|
years: [],
|
|
|
id: null
|
|
|
});
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ if (!dareData) {
|
|
|
+ const fetchData = async () => {
|
|
|
+ const fetchedData = await fetchJsonData();
|
|
|
+ setDareData(fetchedData);
|
|
|
+ };
|
|
|
+
|
|
|
+ fetchData();
|
|
|
+ }
|
|
|
+ }, [dareData]);
|
|
|
|
|
|
const handleModalStateChange = (updates: { [key: string]: any }) => {
|
|
|
setModalState((prevState) => ({ ...prevState, ...updates }));
|
|
@@ -216,7 +228,7 @@ const MapScreen: React.FC<MapScreenProps> = ({ navigation }) => {
|
|
|
}
|
|
|
const thisToken = ++currentTokenRef.current;
|
|
|
|
|
|
- if (!regions || !dareRegions) return;
|
|
|
+ if (!regions || !dareData) return;
|
|
|
|
|
|
if (currentZoom < 7) {
|
|
|
setMarkers([]);
|
|
@@ -315,7 +327,7 @@ const MapScreen: React.FC<MapScreenProps> = ({ navigation }) => {
|
|
|
let db = getSecondDatabase();
|
|
|
let tableName = 'places';
|
|
|
|
|
|
- let foundRegion = findRegionInDataset(dareRegions, point);
|
|
|
+ let foundRegion = findRegionInDataset(dareData, point);
|
|
|
|
|
|
if (!foundRegion) {
|
|
|
foundRegion = findRegionInDataset(regions, point);
|