PHP Classes

PHP Distance between Two Coordinates: Get locations distance with longitude and latitude

Recommend this page to a friend!
  Info   View files Example   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum (4)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 59%Total: 423 This week: 1All time: 6,368 This week: 560Up
Version License PHP version Categories
distance-calculate 1.0.0GNU General Publi...5.0PHP 5, Geography
Description 

Author

This class can get the distance between locations with given coordinates.

It can take the latitude and longitude of two locations and calculates the distance between them.

The distance value can be returned in miles, kilometers or nautical miles.

Picture of Vivek moyal
  Performance   Level  
Name: Vivek moyal is available for providing paid consulting. Contact Vivek moyal .
Classes: 7 packages by
Country: India India
Age: ???
All time rank: 35820 in India India
Week rank: 34 Up2 in India India Up
Innovation award
Innovation award
Nominee: 2x

Winner: 1x

Example

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <?php
       
// $lat1= Your latitude, $lon1= Your Longitude, $lat2= Desired Latitude, $lon2= Desired Longitude
        // $unit can be blank too. If you need the results in Miles than leave it blank else.
        // Use K for kilometre and N for Nautical Miles
       
error_reporting(E_ALL & ~E_NOTICE & ~E_USER_NOTICE);
        include_once
'./calculateDistance.php';
       
$distanceClass=new calculateDistance();
       
$distanceClass->calculate($lat1, $lon1, $lat2, $lon2, $unit);
       
       
//For testing purpose uncomment the below line
       
echo $distanceClass->calculate("26.896623", "75.745167", "26.894555", "75.742460", "K");
   
       
?>
</body>
</html>


  Files folder image Files  
File Role Description
Plain text file calculateDistance.php Class For calculating the distance of the given latitude and longitude
Accessible without login Plain text file index.php Example Example code for using the class

 Version Control Unique User Downloads Download Rankings  
 0%
Total:423
This week:1
All time:6,368
This week:560Up
User Ratings User Comments (2)
 All time
Utility:87%StarStarStarStarStar
Consistency:81%StarStarStarStarStar
Documentation:-
Examples:75%StarStarStarStar
Tests:-
Videos:-
Overall:59%StarStarStar
Rank:1300