1alert(calcCrow(59.3293371,13.4877472,59.3225525,13.4619422).toFixed(1));
2
3
4
5    //This function takes in latitude and longitude of two location and returns the distance between them as the crow flies (in km)
6    function calcCrow(lat1, lon1, lat2, lon2) 
7    {
8      var R = 6371; // km
9      var dLat = toRad(lat2-lat1);
10      var dLon = toRad(lon2-lon1);
11      var lat1 = toRad(lat1);
12      var lat2 = toRad(lat2);
13
14      var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
15        Math.sin(dLon/2) * Math.sin(dLon/2) * Math.cos(lat1) * Math.cos(lat2); 
16      var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); 
17      var d = R * c;
18      return d;
19    }
20
21    // Converts numeric degrees to radians
22    function toRad(Value) 
23    {
24        return Value * Math.PI / 180;
25    }