<?php
/*************************************************************
 * This block of code is here to enable source display.
 * This is because this is demonstration code.
 * This would normally never be included in production code.
 */
if (isset($_REQUEST['show_source'])) {
    
show_source(__FILE__);
    exit ;
}
/*************************************************************
 */
include 'api.php';

class 
mapClass {

    
/**
     * function directions
     *
     * @param string $origin
     * The starting location. This should be a
     * free form address or location that contains
     * enough information for Google to unambiguously
     * determine the location.
     *
     * @param string $destination
     * The destination location. This should be a
     * free form address or location that contains
     * enough information for Google to unambiguously
     * determine the location.
     *
     * @param string @mode
     * This should contain one of four values.
     *      Driving
     *      Walking
     *      Bicycling
     *      Transit
     *
     * @return The JSON data returned by Google
     * which includes driving directions.
     */
    
public function directions($origin$destination$mode) {
        try {
            
$api = new apiClass("class/credentials.txt");
            
$params = array("origin" => $origin"destination" => $destination"mode" => $mode);
            
$apiURL 'https://maps.googleapis.com/maps/api/directions/json';
            
$directions $api -> callAPI($apiURL$params);
            return 
$directions;
        } catch(
Exception $e) {
            return 
json_encode(array("status" => $e -> getMessage()));
        }
    }

}
?>