Skip to content

Instantly share code, notes, and snippets.

@dmozzy
Created April 16, 2012 13:00
Show Gist options
  • Star 22 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save dmozzy/2398636 to your computer and use it in GitHub Desktop.
Save dmozzy/2398636 to your computer and use it in GitHub Desktop.
Calculate Distance using google.maps.geometry.spherical.computeDistanceBetween
<script src="http://maps.google.com/maps/api/js?sensor=false&libraries=geometry" type="text/javascript"></script>
<script type="text/javascript">
function calcDistance (fromLat, fromLng, toLat, toLng) {
return google.maps.geometry.spherical.computeDistanceBetween(
new google.maps.LatLng(fromLat, fromLng), new google.maps.LatLng(toLat, toLng));
}
</script>
@bernajs
Copy link

bernajs commented May 11, 2017

Nice, thanks a lot <3

@cagb80
Copy link

cagb80 commented Jun 17, 2018

Thank You... this worked for me!

@kevinzie
Copy link

Thanks man... You save my day T_T

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment