Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

184
Visualizações
Unhandled promise rejection type error undefined is not a function near ...navigator.geolocation.getcurrentpositionasync...]

My app requests permission to access a user's location in Screen A, so their location renders on a map in Screen B. When navigating to Screen B, I'm hit with a promise rejection, and the map not loading.

Below is my code:

Spins until current location permissions are granted

const renderLoading = () =>  {
    if (isLoading) {
      return (         
          <View style = {styles.indicator}>
            <ActivityIndicator
              color = 'black'
              size = 'large'
              animated = {false}
            />
            <Text style = { styles.text }>{i18n.t('locate')}</Text>
          </View>
          );
          }else {
            return null;
          }
    }

UseFocusEffect that gets geolocation

useFocusEffect( 
      React.useCallback(()=> {
        let isActive = true;
          
          const fetchGeoPosition = async() => {
             navigator.geolocation.getCurrentPositionAsync( //claims undefined is not a function
              position => { 
                if (isActive){
                  setUserLatitude(position.coords.latitude);
                  setUserLongitude(position.coords.longitude);
                  setPositionError(null);
                  console.log('Location Accessed')
                } 
                setIsLoading(false)
              }, 

              error => isActive && setPositionError(error.message),
              {enableHighAccuracy: true, timeout: 0, maximumAge: 1000} 
            ); 
          }

How I deploy onto the map

<View style = {styles.container}>
          {(renderLoading())}

            <View style = {styles.header}>
       
            <MapView
                provider={PROVIDER_GOOGLE}
                style={styles.map}
                region= {{
                  latitude: user_latitude,
                  longitude: user_longitude,
                  latitudeDelta: 0.1451,
                  longitudeDelta: 0.1451
                }}
            >
            <Marker 
              coordinate={ 
                {latitude: user_latitude,
                 longitude: user_longitude,
                 error: position_error,
                }}
            />
        </MapView>
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda