=== modified file 'geotaxonomy.module'
--- geotaxonomy.module	2010-05-10 15:14:57 +0000
+++ geotaxonomy.module	2010-05-10 17:35:44 +0000
@@ -17,6 +17,25 @@
     '#default_value' => variable_get("geotaxonomy_$vid", 0),
     '#description' => t('Allows latitude and longitude data to be stored with terms of this taxonomy.'),
   );
+  
+  if (module_exists('geocode')) {
+	  $geocoder_handlers = array(
+	    FALSE => t('No automatic coordinate retrieval.'),
+	  );
+	  foreach (geocode_handler_info() as $key => $handler) {
+	  	// Only enable handlers that parse text.
+	  	if (isset($handler['return types']['text'])) {
+	  	  $geocoder_handlers[$key] = $handler['label'];
+	  	}
+	  }
+	  $form['settings']['geotaxonomy_geocode'] = array(
+	    '#type' => 'select',
+	    '#title' => t('Automatically retrieve term coordinates using the following service'),
+	    '#default_value' => variable_get("geotaxonomy_".$form['vid']['#value']."_geocode_handler", FALSE),
+	    '#options' => $geocoder_handlers,
+	  );
+  }
+  
   $form['#submit'][]   = 'geotaxonomy_form_vocabulary_submit';
 }
 
@@ -26,6 +45,9 @@
 function geotaxonomy_form_vocabulary_submit($form, &$form_state) {
   $vid = $form_state['values']['vid'];
   variable_set("geotaxonomy_$vid", $form_state['values']['geotaxonomy_status']);
+  if (module_exists('geocode')) {
+    variable_set("geotaxonomy_{$vid}_geocode_handler", $form_state['values']['geotaxonomy_geocode']);
+  }
 }
 
 /**
@@ -46,6 +68,15 @@
     '#title' => t("Geotaxonomy data"),
     '#collapsible' => 1,
   );
+  if (module_exists('geocode')) {
+	  if (variable_get("geotaxonomy_{$vid}_geocode_handler", FALSE)) {
+	  	$form['geotaxonomy']['geocode'] = array(
+	  	  '#type' => 'checkbox',
+	  	  '#title' => t('Retrieve the coordinates based on the taxonomy name'),
+	  	  '#default_value' => TRUE,
+	  	);
+	  }
+  }
   $form['geotaxonomy']['lat'] = array (
     '#type'   => 'textfield',
     '#title'         => t('Latitude'),
@@ -137,6 +168,16 @@
       case 'update':
         db_query("DELETE FROM {term_geo} WHERE tid = %d", $term['tid']);
       case 'insert':
+      	if (module_exists('geocode')) {
+      		$handler = variable_get('geotaxonomy_'. $term['vid'] .'_geocode_handler', FALSE);
+	      	if ($term['geocode'] && $handler) {
+		      	$lat_lon = geocode($handler, $term['name']);
+		      	if ($lat_lon) {
+		      		$term['lat'] = $lat_lon['lat'];
+		      		$term['lon'] = $lat_lon['lon'];
+		      	}
+	      	}
+      	}
         drupal_write_record('term_geo', $term);
         break;
     }

