public class DistanceInMeter { public static double distFrom(double lat1, double lng1, double lat2, double lng2) { double earthRadius = 3958.75; double dLat = toRadians(lat2-lat1); double dLng = toRadians(lng2-lng1); double a = Math.Sin(dLat/2) * Math.Sin(dLat/2) + Math.Cos(Math.toRadians(lat1)) * Math.Cos(Math.toRadians(lat2)) * Math.Sin(dLng/2) * Math.Sin(dLng/2); double c = 2 * Math.Atan2(Math.sqrt(a), Math.sqrt(1-a)); double dist = earthRadius * c; int meterConversion = 1609; return (dist * meterConversion); } static double toRadians(double degree) { return (degree*0.0174532925 ); } }