Skip to content

Instantly share code, notes, and snippets.

@dmozzy
Created April 16, 2012 13:00
Show Gist options
  • 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>
@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