Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Distance calculation from my location to destination location in android

I have to made a project where i need to calculate the distance from my location to destination location and show it in a textview.Here note that this distance updated when my location change.Is it possible to make such type of project ?

[NOTE: without implementing Google map i have to make it.The destination lon ,lat is known.Just have to find my location and make the calculation]

like image 354
MBMJ Avatar asked May 21 '12 10:05

MBMJ


1 Answers

check the documentation on the google android dev page to see how to listen for position changes. http://developer.android.com/guide/topics/location/obtaining-user-location.html

you can use this function to determine the distance between the current (start) point and the target point.

 /**
 * using WSG84
 * using the Metric system
 */
public static float getDistance(double startLati, double startLongi, double goalLati, double goalLongi){
    float[] resultArray = new float[99];
    Location.distanceBetween(startLati, startLongi, goalLati, goalLongi, resultArray);
    return resultArray[0];
}
like image 127
CAA Avatar answered Oct 21 '22 05:10

CAA