The
needs to be positioned to get the latitude and longitude and calculate the distance when doing the project, using HTML5 to obtain the latitude and longitude degree.
<! doctype html>
Calculation formula for distance between two degrees of latitude and longitude
/** * @desc based on latitude and longitude between two points * @param float $lat Latitude value * @param float $lng Longitude value */ public function getdistance ($lat 1, $lng 1, $
lat2, $lng 2) { $earthRadius = 6367000;
$lat 1 = ($lat 1 * pi () ) / 180;
$lng 1 = ($lng 1 * pi () ) / 180;
$lat 2 = ($lat 2 * pi () ) / 180;
$lng 2 = ($lng 2 * pi () ) / 180;
$calcLongitude = $lng 2 - $lng 1;
$calcLatitude = $lat 2 - $lat 1; $stepOne = pow (sin ($calcLatitude / 2), 2) + cos ($lat 1)
* cos ($lat 2) * pow (sin ($calcLongitude / 2), 2); $stepTwo = 2 * asin (min 1, sqrt ($stepOne));
$calculatedDistance = $earthRadius * $stepTwo;
return round ($calculatedDistance); }