Browse Source

Cleaned and formatted code a bit for output display.

Signed-off-by: Rick Hays <rhays@haysgang.com>
master
Rick Hays 6 years ago
parent
commit
4d492bd65e
  1. 13
      geocode-example.php

13
geocode-example.php

@ -5,19 +5,24 @@
$geocode = new geocode(); $geocode = new geocode();
// -- Straight Line Distance ------------------------------------------------------------------------------------------- // -- 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 $geocode->straight_line_distance(39.10968, -94.57949, 39.17521, -94.53957) ;
echo '<br/>' . str_repeat('=',60) . '<br/>'; echo '<br/><br/>' . str_repeat('=',60) . '<br/>';
// -- Get the Lat/Lon of a address ------------------------------------------------------------------------------------- // -- Get the Lat/Lon of a address -------------------------------------------------------------------------------------
$latlong = $geocode->getLatLong('1600 Pennsylvania Ave NW, Washington, DC 20500'); $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 'STATUS: ' . $latlong['status'] . '<br />';
echo 'LAT: ' . $latlong['lat'] . '<br />'; echo 'LAT: ' . $latlong['lat'] . '<br />';
echo 'LON: ' . $latlong['lon'] . '<br />'; echo 'LON: ' . $latlong['lon'] . '<br />';
echo '<br/>' . str_repeat('=',60) . '<br/>'; echo '<br/>' . str_repeat('=',60) . '<br/>';
// -- Drive Distance --------------------------------------------------------------------------------------------------- // -- Drive Distance ---------------------------------------------------------------------------------------------------
$origin = '1600 Pennsylvania Ave NW, Washington, DC 20500'; $origin = '1600 Pennsylvania Ave NW, Washington, DC 20500 <br/>';
$destination = '1313 Mockingbird Lane, North Hollywood, CA 91602'; $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'); $dist = $geocode->getDistance($origin, $destination, 'driving', 'imperial');
echo 'STATUS: ' . $dist['status'] . '<br/>'; echo 'STATUS: ' . $dist['status'] . '<br/>';
echo 'DISTANCE: ' . $dist['distance'] . '<br/>'; echo 'DISTANCE: ' . $dist['distance'] . '<br/>';

Loading…
Cancel
Save