Which one is best to calculate distance between two points?
android, distance
Solution
This link might be helpful to you.
it allows to calculate the distance between two latitude longitude points:
This script calculates great-circle distances between the two points (i.e)the shortest distance over the earth’s surface using the ‘Haversine’ formula.
var R = 6371; // Radius of the earth in km
var dLat = (lat2-lat1).toRad(); // Javascript functions in radians
var dLon = (lon2-lon1).toRad();
var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.cos(lat1.toRad()) * Math.cos(lat2.toRad()) *
Math.sin(dLon/2) * Math.sin(dLon/2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
var d = R * c; // Distance in km.
Problem
I tried to calculate the distance between two points in Google map. Some of the link i found they are using `distanceTo()` and somewhere it is calculated using `distanceBetween()`. Which is best to calculate distance?