Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

213
Vistas
error when accessing latitude and longitude value in geolib

In my react native app I have used geolib to find the nearest place to a certain point from a list of places, like this

const nearestPlace = geolib.findNearest({ latitude:6.4423456, longitude:75.9095818 }, (places));

once I console log nearestPlace I get one latitude, longitude pair but when I try to get the value of the latitude like this,

const latitudeValue = nearestPlace.latitude

It's giving me an error saying property latitude does not exist on type 'GeolibInputCoordinates' so I can't get the latitude value.

Any Idea how to solve this?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I'd suggest you use the getLatitude, getLongitude functions. This will give you values for the latitude and longitude.

Perhaps your places array is in a different format such as { lat, lon } and this is what is causing the issue. They may not necessarily have a latitude or longitude property.

const places = [{ lat: 6.45, lon: 75.90 }, { lat: 6.44, lon: 75.91 }];
let nearestPlace = geolib.findNearest({ latitude: 6.4423456, longitude: 75.9095818 }, (places));
console.log('Nearest place:', nearestPlace);

const latitudeValue = geolib.getLatitude(nearestPlace);
const longitudeValue = geolib.getLongitude(nearestPlace);

console.log('Latitude:', latitudeValue);
console.log('Longitude:', longitudeValue);

// You can also 'normalize' this like so: 

const point = { latitude: latitudeValue, longitude: longitudeValue};
console.log('Nearest point (normalized):', point);
.as-console-wrapper { max-height: 100% !important; top: 0; }
<script src="https://unpkg.com/geolib@3.3.1/lib/index.js"></script> 

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda