import { StyleSheet } from 'react-native'
import MapLibreGL, { Camera, FillLayer, LineLayer, MapView, PointAnnotation, RasterLayer, RasterSource, ShapeSource, UserLocation, UserTrackingMode } from '@maplibre/maplibre-react-native'
import { FontAwesome5, MaterialIcons } from '@expo/vector-icons'
import { circle } from '@turf/circle'
import { useLastOwnLocation, useLastPlayerLocations } from '@/hooks/useLocation'
import React, { useMemo, useState } from 'react'
import { PlayerLocation } from '@/utils/features/location/locationSlice'
import { useGame } from '@/hooks/useGame'
import { FAB } from 'react-native-paper'
export default function Map() {
const [followUser, setFollowUser] = useState(true)
return (
<>
}
onPress={() => setFollowUser(followUser => !followUser)} />
>
)
}
function MapComponent({ followUser, setFollowUser }: { followUser?: boolean, setFollowUser: React.Dispatch> }) {
MapLibreGL.setAccessToken(null)
const userLocation = useLastOwnLocation()
return (
{userLocation && {
if (followUser && !event.nativeEvent.payload.followUserLocation)
setFollowUser(false)
}} />}
)
}
function PlayerLocationsMarkers() {
const game = useGame()
const lastPlayerLocations = useLastPlayerLocations()
return lastPlayerLocations ? lastPlayerLocations
.filter(() => game.currentRunner === true || !game.gameStarted)
.filter(playerLoc => playerLoc.playerId !== game.playerId)
.map(playerLoc => ) : <>>
}
function PlayerLocationMarker({ playerLocation }: { playerLocation: PlayerLocation }) {
const accuracyCircle = useMemo(() => circle([playerLocation.longitude, playerLocation.latitude], playerLocation.accuracy, {steps: 64, units: 'meters'}), [playerLocation])
return <>
>
}
const styles = StyleSheet.create({
map: {
flex: 1,
alignSelf: 'stretch',
}
})