I want to make an app which checks the nearest place where a user is. I can easily get the location of the user and I have already a list of places with latitude and longitude.
What would be the best way to know the nearest place of the list against the current user location.
I could not find anything in the google APIs.
Location loc1 = new Location(""); loc1.setLatitude(lat1); loc1.setLongitude(lon1); Location loc2 = new Location(""); loc2.setLatitude(lat2); loc2.setLongitude(lon2); float distanceInMeters = loc1.distanceTo(loc2);
Look into distanceTo or distanceBetween. You can create a Location object from a latitude and longitude:
Location location = new Location(""); location.setLatitude(lat); location.setLongitude(lon);