Calculate distance between two geolocs in JavaScript
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/27928/how-do-i-calculate-distance-between-two-latitude-longitude-points">How do I calculate distance between two latitude-longitude points?</a>  </p>
</blockquote>



<p>How can I calculate the distance in meters between to geo locations in JavaScript? I found this <a href="http://stackoverflow.com/questions/8832071/how-can-i-get-the-distance-between-two-point-by-latlng">answer</a> but it is implemented in Java, and I did not really understand what was going on.</p>

<p>I am using HTML 5's geo location feature and using JavaScript to calculate the distance. Till now I have this function:</p>

<pre><code>    function calculateDistance(lat1, lat2, lng1, lng2)
    {
        return Math.sqrt(((lat1 + lat2)*(lat1 + lat2)) + ((lng1  + lng2)*(lng1  + lng2)));
    }
</code></pre>

<p>Obviously this is not the value I require. Can anybody help me please?</p>
