diff --git a/gmap.install b/gmap.install
index 2e9f3be..1bb97a7 100644
--- a/gmap.install
+++ b/gmap.install
@@ -19,7 +19,8 @@ function gmap_uninstall() {
   variable_del('gmap_node_markers');
   variable_del('gmap_private_markerfile');
 
-  variable_del('googlemap_api_key');
+  variable_del('googlemap_api_keys');
+  
 }
 
 /**
diff --git a/gmap.module b/gmap.module
index ebc6a5d..b713b7a 100644
--- a/gmap.module
+++ b/gmap.module
@@ -1272,13 +1272,40 @@ function gmap_keys_service() {
  * Retrieve the Google Maps key that is in use for the site.
  */
 function gmap_get_key() {
-  $key = variable_get('googlemap_api_key', '');
+  $key = '';
+
   if (module_exists('keys_api')) {
     $key = keys_api_get_key('gmap', $_SERVER['HTTP_HOST']);
   }
   elseif (module_exists('keys')) {
     $key = keys_get_key('google_maps');
   }
+  else {
+    $keys = variable_get('googlemap_api_keys');
+    $host = $_SERVER['HTTP_HOST'];
+    
+    // Early return nothing if no keys in our array.
+    if (empty($keys)) {
+      return;
+    }
+    
+    foreach($keys as $key_ => $values) {
+      // If we only have one entry in the googlemap_api_keys
+      // array, add its api_key regardless of whether it matches
+      // the host or not.
+      if (count($keys) == 1) {
+        $key = $values['api_key'];
+        break;
+      }
+      else {
+        $pattern = '/' . $host . '/';
+        $match = preg_match($pattern, $values['host']);
+        if ($match) {
+          $key = $values['api_key'];
+        }
+      }
+    }
+  }
   return $key;
 }
 
diff --git a/gmap_settings_ui.inc b/gmap_settings_ui.inc
index 6317c50..317a46d 100644
--- a/gmap_settings_ui.inc
+++ b/gmap_settings_ui.inc
@@ -18,24 +18,72 @@ function gmap_admin_settings($form, &$form_state) {
   );
 
   if (!module_exists('keys_api') && !module_exists('keys')) {
-    $form['initialization']['googlemap_api_key'] = array(
+    $keys = variable_get('googlemap_api_keys', array());
+    
+    $form['initialization']['googlemap_api_keys'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Google Maps API keys'),
+      '#description' => t('Specify an API Key/Host pair for each domain that your Drupal installation serves. You must get these for each separate domain at <a href="http://code.google.com/apis/maps/signup.html">Google Maps API website</a>.<br />If you want to add an additional pair, save this form and return here.'),
+      '#tree' => TRUE,
+    );
+    
+    foreach($keys as $key => $values) {
+      // Since empty values still get added to the variable on submit, catch
+      // and remove them here.
+      if ($values['api_key'] == '') {
+        unset($keys[$key]);
+      } 
+      else {
+        // Add the existing entries to the form.
+        $form['initialization']['googlemap_api_keys'][$key] = array(
+          '#type' => 'fieldset',
+        );
+
+        $form['initialization']['googlemap_api_keys'][$key]['api_key'] = array(
+          '#type' => 'textfield',
+          '#title' => t('API Key'),
+          '#description' => t('Your Google Maps API key.'),
+          '#default_value' => $values['api_key'],
+        );
+        $form['initialization']['googlemap_api_keys'][$key]['host'] = array(
+          '#type' => 'textfield',
+          '#description' => t('The host name to use with your specified key. If blank, I will assume this key is default. Please supply this in the format example.com (that is, omitting "www" and "http://"). Your current hostname is <em>' . $_SERVER['HTTP_HOST'] . '</em>.'),
+          '#title' => t('Hostname'),
+          '#default_value' => $values['host'],
+        );
+      }
+    }
+    
+    // The "define new pair" form fields.
+    $f = array(
+      '#type' => 'fieldset',
+      '#title' => t('Define a new pair'),
+    );
+    
+    $f['api_key'] = array(
+      '#type' => 'textfield',
+      '#title' => t('API Key'),
+      '#description' => t('Your Google Maps API key.'),
+    );
+    
+    $f['host'] = array(
       '#type' => 'textfield',
-      '#default_value' => variable_get('googlemap_api_key', ''),
-      '#size' => 50,
-      '#maxlength' => 255,
+      '#title' => t('Hostname'),
+      '#description' => t('The host name to use with your specified key. If blank, I will assume this key is default. Please supply this in the format example.com (that is, omitting "www" and "http://"). Your current hostname is <em>' . $_SERVER['HTTP_HOST'] . '</em>.'),
     );
+    
+    // Add the "define new pair" form to the existing form array.
+    $form['initialization']['googlemap_api_keys'][] = $f;
+    
   }
   else {
-    $form['initialization']['googlemap_api_key'] = array(
+    $form['initialization']['googlemap_api_keys'] = array(
       '#type' => 'item',
       '#title' => t('Google Maps API Key'),
       '#value' => t('Managed by <a href="@url">Keys</a>.', array('@url' => url('admin/settings/keys'))),
     );
   }
 
-  $form['initialization']['googlemap_api_key']['#title'] = t('Google Maps API Key');
-  $form['initialization']['googlemap_api_key']['#description'] = t('Your personal Googlemaps API key.  You must get this for each separate website at <a href="http://code.google.com/apis/maps/signup.html">Google Map API website</a>.');
-
   $form['initialization']['rebuild'] = array(
     '#type' => 'fieldset',
     '#title' => t('Regenerate marker cache'),
