You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.7 KiB

<?php
// == GEOCODE CLASS ====================================================================================================
require_once 'class/geocode.php';
// -- Init Class
$geocode = new geocode();
// -- Straight Line Distance -------------------------------------------------------------------------------------------
echo 'Straight Line Distance between two Lat/Lon <br/><br/>';
echo $geocode->straight_line_distance(39.10968, -94.57949, 39.17521, -94.53957) ;
echo '<br/><br/>' . str_repeat('=',60) . '<br/>';
// -- Get the Lat/Lon of a address -------------------------------------------------------------------------------------
$address = '1600 Pennsylvania Ave NW, Washington, DC 20500 <br/><br/>';
echo 'Lat/Lon of address: ' . $address;
$latlong = $geocode->getLatLong($address);
echo 'STATUS: ' . $latlong['status'] . '<br />';
echo 'LAT: ' . $latlong['lat'] . '<br />';
echo 'LON: ' . $latlong['lon'] . '<br />';
echo '<br/>' . str_repeat('=',60) . '<br/>';
// -- Drive Distance ---------------------------------------------------------------------------------------------------
$origin = '1600 Pennsylvania Ave NW, Washington, DC 20500 <br/>';
$destination = '1313 Mockingbird Lane, North Hollywood, CA 91602 <br/>';
echo 'Drive Distance: <br/>';
echo 'From: ' . $origin . ' to: ' . $destination . '<br/>';
$dist = $geocode->getDistance($origin, $destination, 'driving', 'imperial');
echo 'STATUS: ' . $dist['status'] . '<br/>';
echo 'DISTANCE: ' . $dist['distance'] . '<br/>';
echo 'DURATION: ' . $dist['duration'] . '<br/>';
echo '<br/>' . str_repeat('=',60) . '<br/>';
// == END SCRIPT =======================================================================================================