double lat1 = coordinate1.latitude * M_1_PI/180;
double lat2 = coordinate2.latitude * M_1_PI/180;
double lon1 = coordinate1.longitude * M_1_PI/180;
double lon2 = coordinate2.longitude * M_1_PI/180;
double r = 6371;
double dlat = lat2 - lat1;
double dlon = lon2 - lon1;
double a = sin(dlat/2) * sin(dlat/2) + cos(lat1) * cos(lat2) * sin(dlon/2) * sin(dlon/2);
double c = 2 * atan2(sqrt(a), sqrt(1-a));
distance = distance + (r * c * 1000);
here it is the code i'm using and it will add the distance continously for the new location of user from his first location. pls tell me i'm doing anything wrong and i'm getting the distance
in meters. the result is always coming like this.
if original distance is between the coordinates is 10.97 meters, for me it was only 1.097 meters Any help is appreciable