Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Detect distance between geo points.
function deg2rad (angle) {
return angle * .017453292519943295;
function distance($lat1,$lng1,$lat2,$lng2)
$delta_lat=($lat2 - $lat1);
$delta_lng=($lng2 - $lng1);
return round(6378137 * acos(cos($lat1) * cos($lat2) * cos($lng1 - $lng2) + sin($lat1) * sin($lat2)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment