0

Im developping an Android app witch contains a list of saved place. Each place is defined by latitude and longitude. The problem is want to compare those coordinate with the current location of the user (define with his current location) to find the more closer place.

I have no problem to get the user's coordinate but i don't have any idea how to proceed.

I still search on internet but found nothing. Thanks if you can help me

Waarx
  • 19
  • 4
  • https://developer.android.com/training/location/retrieve-current –  Apr 27 '18 at 21:28
  • To clarify, you have the user's location as lat/lon, and a series of points as lat/lon, and you'd like to find which of them is closest to the user? – HarlandMason Apr 27 '18 at 21:29
  • I have the lat/lon of the user and i want to find the closest place to the user – Waarx Apr 27 '18 at 21:36
  • I'm afraid I still do not understand. "The closest place." Does that mean "closest of a list of places that I have saved as lat/lon", right? In that case, would it be fair to say that your problem is you need a way to compute the distances between two points defined by lat and lon? – HarlandMason Apr 27 '18 at 21:39
  • Yes, but i don't have the method to do it that's why im blocking on it :( – Waarx Apr 27 '18 at 21:43

1 Answers1

0

What you need to do is sort the list of place in ascending order. The comparison should be based on the distance from the user location, check this answer on how get the distance between two points.

Kuti Gbolahan
  • 2,379
  • 1
  • 9
  • 17