Created
April 4, 2011 14:04
-
-
Save codeswimmer/901677 to your computer and use it in GitHub Desktop.
Android: calculate the distance between two locations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static final float[] calculateDistanceTo(Location fromLocation, Location toLocation) { | |
| float[] results = new float[]; | |
| double startLatitude = fromLocation.getLatitude(); | |
| double startLongitude = fromLocation.getLongitude(); | |
| double endLatitude = toLocation.getLatitude(); | |
| double endLongitude = toLocation.getLongitude(); | |
| fromLocation.distanceBetween(startLatitude, startLongitude, endLatitude, endLongitude, results); | |
| return results; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment