We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mapbox
10.1.31
0.74.3
Android
@rnmapbox/maps
import React, { useEffect, useMemo, useRef, useState } from 'react'; import { StyleSheet, View } from 'react-native'; import Mapbox from '@rnmapbox/maps'; import { NativeStackScreenProps } from '@react-navigation/native-stack'; import { SharedStackParamList } from '../../core/navigation/RootNavigator.tsx'; import { useStylesheet } from '../../hooks/useStylesheet.ts'; import { Theme } from '../../types'; import { userSelectors } from '../../store/user.ts'; import { useSelector } from 'react-redux'; import { colors, HEIGHT_DEVICE, SHADOW, spacing } from '../../constant'; import { CONFIG } from '../../../config'; import { Col, HeaderLeft, Icon, Row, Text } from '../../components'; import { useApiUseQuery } from '../../hooks/useApiUseQuery.ts'; import { useLocationPermission } from 'react-native-vision-camera'; import { t } from 'i18next'; import { Pee } from '../../types/pee.ts'; import { showBottomModal } from '../../components/modal'; import { PeeDetailMapModal } from './components/PeeDetailMapModal.tsx'; import { FilterButton } from './components/FilterButton.tsx'; import { trigger } from 'react-native-haptic-feedback'; import { Feature, FeatureCollection, Point } from 'geojson'; Mapbox.setAccessToken(CONFIG.MAPBOX_ACCESS_TOKEN); export enum FilterEnum { ALL = '', LAST = 100, } interface PeeFeature extends Feature<Point> { properties: { id: string; }; } export const Map = ({ navigation, route }: Props) => { const passedPee = route.params?.pee; const styles = useStylesheet(createStyles); const camera = useRef<Mapbox.Camera>(null); const map = useRef<Mapbox.MapView>(null); const { hasPermission } = useLocationPermission(); const userCoordinates = useSelector(userSelectors.geolocation); const [selectedFilter, setSelectedFilter] = useState<FilterEnum>(FilterEnum.LAST); const { data, isLoading, error } = useApiUseQuery({ queryKey: [`pees/history-map-${selectedFilter}`], queryUrl: 'pees/history', filters: { limit: selectedFilter, sort: '-createdAt' }, }); const onPressSelectedFilter = (filter: FilterEnum) => { if (filter === FilterEnum.ALL) { setSelectedFilter(FilterEnum.LAST); } if (filter === FilterEnum.LAST) { setSelectedFilter(FilterEnum.ALL); } }; const onPressGoBack = () => { navigation.navigate('Home'); }; useEffect(() => { navigation.setOptions({ headerLeft: () => <HeaderLeft showBack onPressGoBack={onPressGoBack} />, headerRight: () => hasPermission && ( <Row gap={8}> <Col style={styles.centerButton} onPress={onPressCenterPosition}> <Icon icon={['fal', 'location-arrow']} size={18} color={colors.primary} /> </Col> <FilterButton onPress={() => onPressSelectedFilter(selectedFilter)} selectedFilter={selectedFilter} disabled={isLoading} /> </Row> ), }); }, [navigation, hasPermission, selectedFilter, isLoading]); const zoomLevel = passedPee ? 16 : 10; const centerCoordinates = passedPee ? passedPee?.position?.coordinates : userCoordinates?.coordinates; const featureCollection = useMemo<FeatureCollection<Point, PeeFeature['properties']>>( () => ({ type: 'FeatureCollection', features: data?.map((pee: Pee) => ({ type: 'Feature', geometry: { type: 'Point', coordinates: pee.position?.coordinates || [0, 0], }, properties: { id: pee.id, }, })) || [], }), [data], ); const onPressCenterPosition = () => { if (userCoordinates?.coordinates) { trigger('impactLight'); camera.current?.setCamera({ centerCoordinate: userCoordinates.coordinates, zoomLevel: 16, animationDuration: 1000, }); } }; return ( <View style={styles.page}> {hasPermission && ( <Mapbox.MapView ref={map} style={styles.map} styleURL="mapbox://styles/mapbox/light-v11" projection={'globe'} logoEnabled={false} attributionEnabled={false} scaleBarEnabled={false}> <Mapbox.Camera ref={camera} zoomLevel={zoomLevel} centerCoordinate={centerCoordinates} animationMode={'flyTo'} animationDuration={2000} /> <Mapbox.ShapeSource id="clusteredPoints" cluster clusterMaxZoomLevel={16} clusterRadius={30} shape={featureCollection}> <Mapbox.CircleLayer id="clusters" filter={['has', 'point_count']} style={{ circleColor: colors.primary, circleRadius: [ 'interpolate', ['linear'], ['get', 'point_count'], 1, 12, // per 1 punto, raggio 20 5, 15, // per 5 punti, raggio 22 10, 20, // per 10 punti, raggio 20 50, 22, // per 50 punti, raggio 22 100, 25, // per 100 punti, raggio 25 200, 30, // per 200 punti, raggio 30 500, 30, // per 500 punti, raggio 30 750, 30, // per 750 punti, raggio 30 ], circleOpacity: 0.9, circleStrokeWidth: 1, circleStrokeColor: 'white', }} /> <Mapbox.SymbolLayer id="cluster-count" filter={['has', 'point_count']} style={{ textField: '{point_count_abbreviated}', textFont: ['DIN Offc Pro Medium', 'Arial Unicode MS Bold'], textSize: 13, textColor: 'white', }} /> <Mapbox.CircleLayer id="unclustered-point" filter={['!', ['has', 'point_count']]} style={{ circleColor: colors.primary, circleRadius: 10, circleOpacity: 0.9, circleStrokeWidth: 1, circleStrokeColor: 'white', }} /> </Mapbox.ShapeSource> </Mapbox.MapView> )} {!hasPermission && ( <Col alignItems={'center'} mt={HEIGHT_DEVICE / 3} mh={spacing.screenHorizontal}> <Text mt={50} fontSize={16}> {t('you do not have location permission')} </Text> </Col> )} </View> ); }; const createStyles = ({ colors, insets, shapes }: Theme) => StyleSheet.create({ page: { backgroundColor: colors.containerBckGround, flex: 1, }, map: { backgroundColor: colors.containerBckGround, flex: 1, }, centerButton: { justifyContent: 'center', alignItems: 'center', width: 40, height: 40, borderRadius: shapes.md, backgroundColor: colors.white, ...SHADOW.MEDIUM, }, });
Video ^^^
I tried:
IMPORTANT: the bug is only with the android build, in debug mode it works good (ONLY WITH SOME ANDROID, NOT ALL)
Video ^^^^
The text was updated successfully, but these errors were encountered:
Please fix the errors in your code example - More info.:
error: Parsing error: Unexpected token enum at example.jsx:26:8: 24 | Mapbox.setAccessToken(CONFIG.MAPBOX_ACCESS_TOKEN); 25 | > 26 | export enum FilterEnum { | ^ 27 | ALL = '', 28 | LAST = 100, 29 | } 1 error found.```
Sorry, something went wrong.
No branches or pull requests
Mapbox Implementation
Mapbox
Mapbox Version
10.1.31
React Native Version
0.74.3
Platform
Android
@rnmapbox/maps
version10.1.31
Standalone component to reproduce
Observed behavior and steps to reproduce
592a60e0-9a8a-484d-b8f1-4f8847d45e8a.MP4
Expected behavior
Video ^^^
Notes / preliminary analysis
I tried:
IMPORTANT: the bug is only with the android build, in debug mode it works good (ONLY WITH SOME ANDROID, NOT ALL)
Additional links and references
Video ^^^^
The text was updated successfully, but these errors were encountered: