|
@@ -13,7 +13,7 @@ import {
|
|
|
} from 'react-native';
|
|
|
import React, { useEffect, useRef, useState, useCallback } from 'react';
|
|
|
|
|
|
-import MapLibreGL, { CameraRef, MapViewRef, ShapeSourceRef } from '@maplibre/maplibre-react-native';
|
|
|
+import * as MapLibreRN from '@maplibre/maplibre-react-native';
|
|
|
import { styles } from './style';
|
|
|
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
|
import { Colors } from 'src/theme';
|
|
@@ -88,8 +88,7 @@ const defaultUserAvatar = require('assets/icon-user-share-location-solid.png');
|
|
|
const logo = require('assets/logo-ua.png');
|
|
|
const defaultSeriesIcon = require('assets/series-default.png');
|
|
|
|
|
|
-MapLibreGL.setAccessToken(null);
|
|
|
-MapLibreGL.Logger.setLogLevel('error');
|
|
|
+MapLibreRN.Logger.setLogLevel('error');
|
|
|
|
|
|
const generateFilter = (ids: number[]) => {
|
|
|
return ids?.length ? ['any', ...ids.map((id) => ['==', 'id', id])] : ['==', 'id', -1];
|
|
@@ -670,9 +669,9 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
}, [regionPopupVisible, navigation])
|
|
|
);
|
|
|
|
|
|
- const mapRef = useRef<MapViewRef>(null);
|
|
|
- const cameraRef = useRef<CameraRef>(null);
|
|
|
- const shapeSourceRef = useRef<ShapeSourceRef>(null);
|
|
|
+ const mapRef = useRef<MapLibreRN.MapViewRef>(null);
|
|
|
+ const cameraRef = useRef<MapLibreRN.CameraRef>(null);
|
|
|
+ const shapeSourceRef = useRef<MapLibreRN.ShapeSourceRef>(null);
|
|
|
|
|
|
useEffect(() => {
|
|
|
if (userInfo) {
|
|
@@ -1164,7 +1163,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
<SafeAreaView style={{ height: '100%' }}>
|
|
|
<StatusBar translucent backgroundColor="transparent" />
|
|
|
|
|
|
- <MapLibreGL.MapView
|
|
|
+ <MapLibreRN.MapView
|
|
|
ref={mapRef}
|
|
|
style={styles.map}
|
|
|
mapStyle={VECTOR_MAP_HOST + '/nomadmania-maps.json'}
|
|
@@ -1175,7 +1174,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
onRegionIsChanging={handleMapChange}
|
|
|
onRegionWillChange={_.debounce(handleMapChange, 200)}
|
|
|
>
|
|
|
- <MapLibreGL.Images
|
|
|
+ <MapLibreRN.Images
|
|
|
images={images}
|
|
|
onImageMissing={(image) => {
|
|
|
if (processedImages.current.has(image)) {
|
|
@@ -1190,11 +1189,11 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
}}
|
|
|
>
|
|
|
<View />
|
|
|
- </MapLibreGL.Images>
|
|
|
+ </MapLibreRN.Images>
|
|
|
|
|
|
{type === 'regions' && (
|
|
|
<>
|
|
|
- <MapLibreGL.LineLayer
|
|
|
+ <MapLibreRN.LineLayer
|
|
|
id="nm-regions-line-layer"
|
|
|
sourceID={regions.source}
|
|
|
sourceLayerID={regions['source-layer']}
|
|
@@ -1207,7 +1206,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
}}
|
|
|
belowLayerID="waterway-name"
|
|
|
/>
|
|
|
- <MapLibreGL.FillLayer
|
|
|
+ <MapLibreRN.FillLayer
|
|
|
id={regions.id}
|
|
|
sourceID={regions.source}
|
|
|
sourceLayerID={regions['source-layer']}
|
|
@@ -1216,7 +1215,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
maxZoomLevel={regions.maxzoom}
|
|
|
belowLayerID={regions_visited.id}
|
|
|
/>
|
|
|
- <MapLibreGL.FillLayer
|
|
|
+ <MapLibreRN.FillLayer
|
|
|
id={regions_visited.id}
|
|
|
sourceID={regions_visited.source}
|
|
|
sourceLayerID={regions_visited['source-layer']}
|
|
@@ -1229,7 +1228,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
)}
|
|
|
{type === 'countries' && (
|
|
|
<>
|
|
|
- <MapLibreGL.LineLayer
|
|
|
+ <MapLibreRN.LineLayer
|
|
|
id="countries-line-layer"
|
|
|
sourceID={countries.source}
|
|
|
sourceLayerID={countries['source-layer']}
|
|
@@ -1242,7 +1241,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
}}
|
|
|
belowLayerID="waterway-name"
|
|
|
/>
|
|
|
- <MapLibreGL.FillLayer
|
|
|
+ <MapLibreRN.FillLayer
|
|
|
id={countries.id}
|
|
|
sourceID={countries.source}
|
|
|
sourceLayerID={countries['source-layer']}
|
|
@@ -1251,7 +1250,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
maxZoomLevel={countries.maxzoom}
|
|
|
belowLayerID={countries_visited.id}
|
|
|
/>
|
|
|
- <MapLibreGL.FillLayer
|
|
|
+ <MapLibreRN.FillLayer
|
|
|
id={countries_visited.id}
|
|
|
sourceID={countries_visited.source}
|
|
|
sourceLayerID={countries_visited['source-layer']}
|
|
@@ -1264,7 +1263,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
)}
|
|
|
{type === 'dare' && (
|
|
|
<>
|
|
|
- <MapLibreGL.FillLayer
|
|
|
+ <MapLibreRN.FillLayer
|
|
|
id={dare.id}
|
|
|
sourceID={dare.source}
|
|
|
sourceLayerID={dare['source-layer']}
|
|
@@ -1273,7 +1272,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
maxZoomLevel={dare.maxzoom}
|
|
|
belowLayerID={dare_visited.id}
|
|
|
/>
|
|
|
- <MapLibreGL.FillLayer
|
|
|
+ <MapLibreRN.FillLayer
|
|
|
id={dare_visited.id}
|
|
|
sourceID={dare_visited.source}
|
|
|
sourceLayerID={dare_visited['source-layer']}
|
|
@@ -1285,7 +1284,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
</>
|
|
|
)}
|
|
|
{selectedRegion && type && (
|
|
|
- <MapLibreGL.FillLayer
|
|
|
+ <MapLibreRN.FillLayer
|
|
|
id={selected_region.id}
|
|
|
sourceID={type}
|
|
|
sourceLayerID={type}
|
|
@@ -1296,13 +1295,13 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
/>
|
|
|
)}
|
|
|
|
|
|
- <MapLibreGL.VectorSource
|
|
|
+ <MapLibreRN.VectorSource
|
|
|
id="nomadmania_series"
|
|
|
tileUrlTemplates={[VECTOR_MAP_HOST + '/tiles/series/{z}/{x}/{y}.pbf']}
|
|
|
onPress={handleMarkerPress}
|
|
|
>
|
|
|
{seriesFilter.status !== 1 && Object.keys(images).length > 0 ? (
|
|
|
- <MapLibreGL.SymbolLayer
|
|
|
+ <MapLibreRN.SymbolLayer
|
|
|
id={series_layer.id}
|
|
|
sourceID={series_layer.source}
|
|
|
sourceLayerID={series_layer['source-layer']}
|
|
@@ -1329,7 +1328,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
)}
|
|
|
|
|
|
{seriesFilter.status !== 0 && Object.keys(images).length > 0 ? (
|
|
|
- <MapLibreGL.SymbolLayer
|
|
|
+ <MapLibreRN.SymbolLayer
|
|
|
id={series_visited.id}
|
|
|
sourceID={series_visited.source}
|
|
|
sourceLayerID={series_visited['source-layer']}
|
|
@@ -1354,10 +1353,10 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
) : (
|
|
|
<></>
|
|
|
)}
|
|
|
- </MapLibreGL.VectorSource>
|
|
|
+ </MapLibreRN.VectorSource>
|
|
|
|
|
|
{nomads && showNomads && (
|
|
|
- <MapLibreGL.ShapeSource
|
|
|
+ <MapLibreRN.ShapeSource
|
|
|
ref={shapeSourceRef}
|
|
|
tolerance={20}
|
|
|
id="nomads"
|
|
@@ -1388,7 +1387,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
cluster={true}
|
|
|
clusterRadius={50}
|
|
|
>
|
|
|
- <MapLibreGL.CircleLayer
|
|
|
+ <MapLibreRN.CircleLayer
|
|
|
id="nomads_circle"
|
|
|
filter={['has', 'point_count']}
|
|
|
aboveLayerID={Platform.OS === 'android' ? 'place-continent' : undefined}
|
|
@@ -1416,7 +1415,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
circleOpacity: 1
|
|
|
}}
|
|
|
/>
|
|
|
- <MapLibreGL.SymbolLayer
|
|
|
+ <MapLibreRN.SymbolLayer
|
|
|
id="nomads_count"
|
|
|
filter={['has', 'point_count']}
|
|
|
aboveLayerID={Platform.OS === 'android' ? 'nomads_circle' : undefined}
|
|
@@ -1442,7 +1441,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
textAllowOverlap: true
|
|
|
}}
|
|
|
/>
|
|
|
- <MapLibreGL.SymbolLayer
|
|
|
+ <MapLibreRN.SymbolLayer
|
|
|
id="nomads_symbol"
|
|
|
filter={['!', ['has', 'point_count']]}
|
|
|
aboveLayerID={Platform.OS === 'android' ? 'place-continent' : undefined}
|
|
@@ -1465,8 +1464,8 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
],
|
|
|
iconAllowOverlap: true
|
|
|
}}
|
|
|
- ></MapLibreGL.SymbolLayer>
|
|
|
- </MapLibreGL.ShapeSource>
|
|
|
+ ></MapLibreRN.SymbolLayer>
|
|
|
+ </MapLibreRN.ShapeSource>
|
|
|
)}
|
|
|
|
|
|
{selectedUser && <UserItem marker={selectedUser} />}
|
|
@@ -1474,9 +1473,9 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
{selectedMarker && (
|
|
|
<MarkerItem marker={selectedMarker} toggleSeries={toggleSeries} token={token} />
|
|
|
)}
|
|
|
- <MapLibreGL.Camera ref={cameraRef} />
|
|
|
+ <MapLibreRN.Camera ref={cameraRef} />
|
|
|
{location && (
|
|
|
- <MapLibreGL.UserLocation
|
|
|
+ <MapLibreRN.UserLocation
|
|
|
animated={true}
|
|
|
showsUserHeadingIndicator={true}
|
|
|
onPress={async () => {
|
|
@@ -1492,9 +1491,9 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
}}
|
|
|
>
|
|
|
{/* to do custom user location */}
|
|
|
- </MapLibreGL.UserLocation>
|
|
|
+ </MapLibreRN.UserLocation>
|
|
|
)}
|
|
|
- </MapLibreGL.MapView>
|
|
|
+ </MapLibreRN.MapView>
|
|
|
|
|
|
{center ? (
|
|
|
<ScaleBar
|