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

210
Visualizações
Get coordinates of where onLongPress event took place - react-native-maps

I am trying to get the lat and lng coords of where a onLongPress event took place. I have the even setup, but do not know where the coords are stored in the event. Anyone have any experience with this?

<MapView
      initialRegion={{
        latitude: props.location.coords.latitude,
        longitude: props.location.coords.longitude,
        latitudeDelta: 0.04,
        longitudeDelta: 0.05,
      }}
      onLongPress={(e) => {
        console.log(e);
      }}
      showsMyLocationButton={true}
      showsUserLocation={true}
      style={styles.map}
    >
      {markers.map((marker, index) => (
        <Marker
          key={index}
          coordinate={marker.latlng}
          title={marker.title}
          description={marker.description}
          onPress={() => navigation.navigate("Marker", { data: marker })}
        ></Marker>
      ))}
    </MapView>

console.log(e) prints out a massive object, but I do not see the coords anywhere in that object.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

It is hidden in e.nativeEvent. Consider the following code snippet in order to access the coordinates.

<MapView
      ...
      onLongPress={(e) => {
        console.log(e.nativeEvent)
      }}
      ...
    >
     ...
</MapView>

The nativeEvent contains the following object.

{
    target: 127,
    coordinate: {
        latitude: 47.66491318510563,
        longitude: 4.238049164414406
     },
     position: {
        y: 489.9999084472656,
        x: 263.99993896484375
     }
}
about 4 years ago · Juan Pablo Isaza Relatório
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