|
@@ -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';
|
|
@@ -68,8 +68,8 @@ import { useGetIconsQuery, usePostSetToggleItem } from '@api/series';
|
|
|
import MarkerItem from './MarkerItem';
|
|
|
import {
|
|
|
usePostGetSettingsQuery,
|
|
|
+ usePostGetUsersCountQuery,
|
|
|
usePostGetUsersLocationQuery,
|
|
|
- usePostIsFeatureActiveQuery,
|
|
|
usePostUpdateLocationMutation
|
|
|
} from '@api/location';
|
|
|
import UserItem from './UserItem';
|
|
@@ -83,17 +83,14 @@ import MapButton from 'src/components/MapButton';
|
|
|
import { useAvatarStore } from 'src/stores/avatarVersionStore';
|
|
|
import _ from 'lodash';
|
|
|
import ScaleBar from 'src/components/ScaleBar';
|
|
|
-// import {
|
|
|
-// startBackgroundLocationUpdates,
|
|
|
-// stopBackgroundLocationUpdates
|
|
|
-// } from 'src/utils/backgroundLocation';
|
|
|
+import MessagesDot from 'src/components/MessagesDot';
|
|
|
|
|
|
+const clusteredUsersIcon = require('assets/icons/icon-clustered-users.png');
|
|
|
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];
|
|
@@ -276,7 +273,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
const netInfo = useConnection();
|
|
|
const { avatarVersion } = useAvatarStore();
|
|
|
|
|
|
- const { data: isFeatureActive } = usePostIsFeatureActiveQuery(token, !!token && isConnected);
|
|
|
+ const { data: usersOnMapCount } = usePostGetUsersCountQuery(token, !!token && isConnected);
|
|
|
const { data: regionsList } = useGetListRegionsQuery(isConnected);
|
|
|
const { data: countriesList } = useGetListCountriesQuery(isConnected);
|
|
|
const { data: dareList } = useGetListDareQuery(isConnected);
|
|
@@ -625,24 +622,9 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
) {
|
|
|
setShowNomads(false);
|
|
|
storage.set('showNomads', false);
|
|
|
- // await stopBackgroundLocationUpdates();
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // const bgStatus = await Location.getBackgroundPermissionsAsync();
|
|
|
- // if (bgStatus.status !== 'granted') {
|
|
|
- // const { status } = await Location.requestBackgroundPermissionsAsync();
|
|
|
- // if (status === Location.PermissionStatus.GRANTED) {
|
|
|
- // await startBackgroundLocationUpdates();
|
|
|
- // console.log('[Permissions] Background granted');
|
|
|
- // } else {
|
|
|
- // console.log('[Permissions] Background denied');
|
|
|
- // }
|
|
|
- // } else {
|
|
|
- // await startBackgroundLocationUpdates();
|
|
|
- // console.log('[Permissions] Background already granted');
|
|
|
- // }
|
|
|
-
|
|
|
try {
|
|
|
let currentLocation = await Location.getCurrentPositionAsync({
|
|
|
accuracy: Location.Accuracy.Balanced
|
|
@@ -689,9 +671,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) {
|
|
@@ -913,19 +895,6 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
|
|
|
if (status === 'granted' && isServicesEnabled) {
|
|
|
await getLocation();
|
|
|
- // const bgStatus = await Location.getBackgroundPermissionsAsync();
|
|
|
- // if (bgStatus.status !== 'granted') {
|
|
|
- // const { status } = await Location.requestBackgroundPermissionsAsync();
|
|
|
- // if (status === Location.PermissionStatus.GRANTED) {
|
|
|
- // await startBackgroundLocationUpdates();
|
|
|
- // console.log('[Permissions] Background granted');
|
|
|
- // } else {
|
|
|
- // console.log('[Permissions] Background denied');
|
|
|
- // }
|
|
|
- // } else {
|
|
|
- // await startBackgroundLocationUpdates();
|
|
|
- // console.log('[Permissions] Background already granted');
|
|
|
- // }
|
|
|
} else if (!canAskAgain || !isServicesEnabled) {
|
|
|
setOpenSettingsVisible(true);
|
|
|
} else {
|
|
@@ -1196,10 +1165,10 @@ 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}
|
|
|
- styleJSON={VECTOR_MAP_HOST + '/nomadmania-maps.json'}
|
|
|
+ mapStyle={VECTOR_MAP_HOST + '/nomadmania-maps.json'}
|
|
|
rotateEnabled={false}
|
|
|
attributionEnabled={false}
|
|
|
onPress={onMapPress}
|
|
@@ -1207,7 +1176,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)) {
|
|
@@ -1222,11 +1191,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']}
|
|
@@ -1239,7 +1208,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']}
|
|
@@ -1248,7 +1217,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']}
|
|
@@ -1261,7 +1230,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']}
|
|
@@ -1274,7 +1243,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']}
|
|
@@ -1283,7 +1252,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']}
|
|
@@ -1296,7 +1265,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']}
|
|
@@ -1305,7 +1274,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']}
|
|
@@ -1317,7 +1286,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
</>
|
|
|
)}
|
|
|
{selectedRegion && type && (
|
|
|
- <MapLibreGL.FillLayer
|
|
|
+ <MapLibreRN.FillLayer
|
|
|
id={selected_region.id}
|
|
|
sourceID={type}
|
|
|
sourceLayerID={type}
|
|
@@ -1328,13 +1297,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']}
|
|
@@ -1361,7 +1330,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']}
|
|
@@ -1386,10 +1355,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"
|
|
@@ -1420,61 +1389,72 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
cluster={true}
|
|
|
clusterRadius={50}
|
|
|
>
|
|
|
- <MapLibreGL.CircleLayer
|
|
|
+ <MapLibreRN.SymbolLayer
|
|
|
id="nomads_circle"
|
|
|
filter={['has', 'point_count']}
|
|
|
aboveLayerID={Platform.OS === 'android' ? 'place-continent' : undefined}
|
|
|
style={{
|
|
|
- circleRadius: [
|
|
|
+ iconImage: clusteredUsersIcon,
|
|
|
+ iconSize: [
|
|
|
'interpolate',
|
|
|
['linear'],
|
|
|
['get', 'point_count'],
|
|
|
0,
|
|
|
- 15,
|
|
|
+ 0.33,
|
|
|
10,
|
|
|
- 17,
|
|
|
+ 0.35,
|
|
|
20,
|
|
|
- 19,
|
|
|
+ 0.37,
|
|
|
50,
|
|
|
- 21,
|
|
|
+ 0.39,
|
|
|
75,
|
|
|
- 23,
|
|
|
+ 0.41,
|
|
|
100,
|
|
|
- 25
|
|
|
+ 0.43
|
|
|
],
|
|
|
- circleColor: 'rgba(237, 147, 52, 1)',
|
|
|
- circleStrokeWidth: 2,
|
|
|
- circleStrokeColor: '#FFFFFF',
|
|
|
- circleOpacity: 1
|
|
|
+ iconAllowOverlap: true
|
|
|
}}
|
|
|
- />
|
|
|
- <MapLibreGL.SymbolLayer
|
|
|
+ ></MapLibreRN.SymbolLayer>
|
|
|
+ <MapLibreRN.SymbolLayer
|
|
|
id="nomads_count"
|
|
|
filter={['has', 'point_count']}
|
|
|
aboveLayerID={Platform.OS === 'android' ? 'nomads_circle' : undefined}
|
|
|
style={{
|
|
|
- textField: ['get', 'point_count'],
|
|
|
+ textField: [
|
|
|
+ 'case',
|
|
|
+ ['<', ['get', 'point_count'], 1000],
|
|
|
+ ['get', 'point_count'],
|
|
|
+ ['concat', ['/', ['round', ['/', ['get', 'point_count'], 100]], 10], 'k']
|
|
|
+ ],
|
|
|
textFont: ['Noto Sans Bold'],
|
|
|
textSize: [
|
|
|
'interpolate',
|
|
|
['linear'],
|
|
|
['get', 'point_count'],
|
|
|
0,
|
|
|
- 13,
|
|
|
+ 13.5,
|
|
|
20,
|
|
|
14,
|
|
|
75,
|
|
|
15
|
|
|
],
|
|
|
textColor: '#FFFFFF',
|
|
|
- textHaloColor: '#000000',
|
|
|
- textHaloWidth: 1,
|
|
|
textAnchor: 'center',
|
|
|
- textOffset: [0, 0],
|
|
|
+ textOffset: [
|
|
|
+ 'interpolate',
|
|
|
+ ['linear'],
|
|
|
+ ['get', 'point_count'],
|
|
|
+ 0,
|
|
|
+ ['literal', [0, 0.85]],
|
|
|
+ 20,
|
|
|
+ ['literal', [0, 0.92]],
|
|
|
+ 75,
|
|
|
+ ['literal', [0, 1]]
|
|
|
+ ],
|
|
|
textAllowOverlap: true
|
|
|
}}
|
|
|
/>
|
|
|
- <MapLibreGL.SymbolLayer
|
|
|
+ <MapLibreRN.SymbolLayer
|
|
|
id="nomads_symbol"
|
|
|
filter={['!', ['has', 'point_count']]}
|
|
|
aboveLayerID={Platform.OS === 'android' ? 'place-continent' : undefined}
|
|
@@ -1497,8 +1477,8 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
],
|
|
|
iconAllowOverlap: true
|
|
|
}}
|
|
|
- ></MapLibreGL.SymbolLayer>
|
|
|
- </MapLibreGL.ShapeSource>
|
|
|
+ ></MapLibreRN.SymbolLayer>
|
|
|
+ </MapLibreRN.ShapeSource>
|
|
|
)}
|
|
|
|
|
|
{selectedUser && <UserItem marker={selectedUser} />}
|
|
@@ -1506,9 +1486,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 () => {
|
|
@@ -1524,9 +1504,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
|
|
@@ -1677,6 +1657,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
showsHorizontalScrollIndicator={false}
|
|
|
contentContainerStyle={{
|
|
|
paddingHorizontal: 12,
|
|
|
+ paddingTop: 6,
|
|
|
gap: isSmallScreen ? 8 : 12,
|
|
|
flexDirection: 'row'
|
|
|
}}
|
|
@@ -1699,7 +1680,6 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
text="Series"
|
|
|
active={seriesFilter.visible}
|
|
|
/>
|
|
|
- {/* {isFeatureActive && isFeatureActive.active ? ( */}
|
|
|
{token ? (
|
|
|
<MapButton
|
|
|
onPress={() => {
|
|
@@ -1709,7 +1689,16 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
icon={NomadsIcon}
|
|
|
text="Nomads"
|
|
|
active={showNomads}
|
|
|
- />
|
|
|
+ >
|
|
|
+ {usersOnMapCount && usersOnMapCount?.count > 0 ? (
|
|
|
+ <MessagesDot
|
|
|
+ messagesCount={usersOnMapCount.count}
|
|
|
+ fullNumber={true}
|
|
|
+ right={-10}
|
|
|
+ top={-8}
|
|
|
+ />
|
|
|
+ ) : null}
|
|
|
+ </MapButton>
|
|
|
) : null}
|
|
|
</ScrollView>
|
|
|
</View>
|
|
@@ -1767,6 +1756,7 @@ const MapScreen: any = ({ navigation, route }: { navigation: any; route: any })
|
|
|
showNomads={showNomads}
|
|
|
isPublicView={false}
|
|
|
isLogged={token ? true : false}
|
|
|
+ usersOnMapCount={token && usersOnMapCount?.count ? usersOnMapCount.count : null}
|
|
|
/>
|
|
|
<EditModal
|
|
|
isVisible={isEditSlowModalVisible}
|