Created
January 29, 2015 14:02
-
-
Save mustafasevgi/dbfae7eccad177090d0a to your computer and use it in GitHub Desktop.
calculate two location
This file contains 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
private String getDistanceBetweenTwoLocations(double latA, double lngA, double latB, double lngB, String suffix) { | |
Location locationA = new Location("point A"); | |
locationA.setLatitude(latA); | |
locationA.setLongitude(lngA); | |
Location locationB = new Location("point B"); | |
locationB.setLatitude(latB); | |
locationB.setLongitude(lngB); | |
float distance = locationA.distanceTo(locationB) / 1000; | |
DecimalFormat df = new DecimalFormat("0.##"); | |
String dst = df.format(distance) + suffix; | |
return dst; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment