diff --git a/class/geocode.php b/class/geocode.php
new file mode 100644
index 0000000..9235966
--- /dev/null
+++ b/class/geocode.php
@@ -0,0 +1,112 @@
+api_key.'&origins='.rawurlencode($origin).'&destinations='.rawurlencode($destination).'&mode=driving&units=imperial&sensor=false
+ *
+ */
+ public function Get_Distance($origin, $destination, $mode='driving', $unit='imperial')
+ {
+ // Set defaults to test for
+ $modes = array('driving', 'walking', 'bicycling');
+ $units = array('metric', 'imperial');
+
+ // Test that addresses are present
+ if (!is_string($origin) || !is_string($destination))die("All Addresses must be passed as a string");
+
+ // Test that Mode is present and of correct value
+ $mode = strtolower($mode);
+ if (!in_array($mode, $modes))die("Mode not correct");
+
+ // Test that Unit is present and of correct value
+ $unit = strtolower($unit);
+ if (!in_array($unit, $units))die("Unit not correct");
+
+ // Prep string for send ie(remove spaces and other objects)
+ $_origin = rawurlencode($origin);
+ $_destination = rawurlencode($destination);
+ $_mode = rawurlencode($mode);
+ $_unit = rawurlencode($unit);
+
+ $_url = sprintf('https://maps.googleapis.com/maps/api/distancematrix/json?%s&origins=%s&destinations=%s&mode=%s&units=%s&sensor=false',API_KEY, rawurlencode($origin), rawurlencode($destination), $_mode, $_unit);
+ if($_result = file_get_contents($_url))
+ {
+ $decode = json_decode($_result,true);
+ $_dist['status'] = $decode['status'];
+ $_dist['distance'] = $decode['rows'][0]['elements'][0]['distance']['text'];
+ $_dist['duration'] = $decode['rows'][0]['elements'][0]['duration']['text'];
+ return $_dist;
+ }else die('Nothing was returned');
+ }
+
+} // End Class GEOCODE
+
+
+
+
diff --git a/geocode-example.php b/geocode-example.php
new file mode 100644
index 0000000..214d7c6
--- /dev/null
+++ b/geocode-example.php
@@ -0,0 +1,27 @@
+straight_line_distance(39.10968, -94.57949, 39.17521, -94.53957) ;
+ echo '
' . str_repeat('=',60) . '
';
+
+// -- Get the Lat/Lon of a address -------------------------------------------------------------------------------------
+ $latlong = $geocode->getLatLong('1600 Pennsylvania Ave NW, Washington, DC 20500');
+ echo 'STATUS: ' . $latlong['status'] . '
';
+ echo 'LAT: ' . $latlong['lat'] . '
';
+ echo 'LON: ' . $latlong['lon'] . '
';
+ echo '
' . str_repeat('=',60) . '
';
+
+// -- Drive Distance ---------------------------------------------------------------------------------------------------
+ $origin = '1600 Pennsylvania Ave NW, Washington, DC 20500';
+ $destination = '4433 N Indiana Ave, Kansas City, MO 64117';
+ $dist = $geocode->Get_Distance($origin, $destination, 'driving', 'imperial');
+ echo 'STATUS: ' . $dist['status'] . '
';
+ echo 'DISTANCE: ' . $dist['distance'] . '
';
+ echo 'DURATION: ' . $dist['duration'] . '
';
+ echo '
' . str_repeat('=',60) . '
';
+
+// == END SCRIPT =======================================================================================================