Files
geocode_class/geocode-example.php
Rick Hays 6bf1da851c Changed drive distance addresses. More notable
White House to Munster House

Also changed function name to match my standard.

Signed-off-by: Rick Hays <rhays@haysgang.com>
2019-09-27 16:48:42 -05:00

28 lines
1.5 KiB
PHP

<?php
// == GEOCODE CLASS ====================================================================================================
require_once 'class/geocode.php';
// -- Init Class
$geocode = new geocode();
// -- Straight Line Distance -------------------------------------------------------------------------------------------
echo $geocode->straight_line_distance(39.10968, -94.57949, 39.17521, -94.53957) ;
echo '<br/>' . str_repeat('=',60) . '<br/>';
// -- Get the Lat/Lon of a address -------------------------------------------------------------------------------------
$latlong = $geocode->getLatLong('1600 Pennsylvania Ave NW, Washington, DC 20500');
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';
$destination = '1313 Mockingbird Lane, North Hollywood, CA 91602';
$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 =======================================================================================================