Created
June 1, 2012 10:07
-
-
Save abarth500/2850927 to your computer and use it in GitHub Desktop.
Distance between two points
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getDistance(point1,point2){ | |
var my = ((point1.lat + point2.lat) / 2.0) * Math.PI / 180.0; | |
var dy = (point1.lat - point2.lat) * Math.PI / 180.0; | |
var dx = (point1.lng - point2.lng) * Math.PI / 180.0; | |
var w = Math.sqrt(1.0 - 0.0066943799901975 * Math.pow(Math.sin(my),2)); | |
return Math.sqrt(Math.pow(dy * 6335439.32729246 / Math.pow(w,3),2) | |
+ Math.pow(dx * 6378137.000 * Math.cos(my) / w,2)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment