Created
December 7, 2016 18:50
-
-
Save arumoy/d57b19089d577094a0298e2b640e93ae to your computer and use it in GitHub Desktop.
Great Circle Distance calculator in JS
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
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&libraries=geometry"></script> | |
<script> | |
var p1 = new google.maps.LatLng(12.851853, 77.664216); | |
var p2 = new google.maps.LatLng(12.851854, 77.664219); | |
alert(calcDistance(p1, p2)); | |
//calculates distance between two points in km's | |
function calcDistance(p1, p2) { | |
return (google.maps.geometry.spherical.computeDistanceBetween(p1, p2)).toFixed(10); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment