Index: supported/location.us.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/location/supported/location.us.inc,v
retrieving revision 1.16.2.2
diff -u -p -r1.16.2.2 location.us.inc
--- supported/location.us.inc	2 Aug 2007 01:57:25 -0000	1.16.2.2
+++ supported/location.us.inc	21 Jul 2010 20:13:35 -0000
@@ -133,23 +133,43 @@ function _location_latlon_exact_us_geoco
 
 function location_map_link_us_yahoo($location = array()) {
   $get_query = '?';
-  if (isset($location['street'])) {
-    $get_query .= 'addr='. urlencode($location['street']) .'&amp;';
+  if (($location['street'] == '') && ($location['city'] == '') && ($location['province'] == '')) {
+    if (isset($location['latitude'])) {
+      $get_query .= 'q1='. urlencode($location['latitude']);
+    }
+
+    if (isset($location['longitude'])) {
+      $get_query .= '+'. urlencode($location['longitude']);
+    }
   }
-  if ($location['province'] != '' || $location['city'] != '' || $location['postal_code'] != '') {
-    $get_query .= 'csz='. _location_us_yahoo_csz_get_field($location) .'&amp;';
+  else {
+    if (isset($location['street'])) {
+      $get_query .= 'addr='. urlencode($location['street']) .'&amp;';
+    }
+    if ($location['province'] != '' || $location['city'] != '' || $location['postal_code'] != '') {
+      $get_query .= 'csz='. _location_us_yahoo_csz_get_field($location) .'&amp;';
+    }
+    $get_query .= 'country='. urlencode($location['country']);
   }
-  $get_query .= 'country='. urlencode($location['country']);
   return ('http://maps.yahoo.com/maps_result'. $get_query);
 }
 
 
 function location_map_link_us_google($location = array()) {
   $query_params = array();
-  
-  foreach (array('street', 'city', 'province', 'postal_code', 'country') as $field) {
-    if (isset($location[$field])) {
-      $query_params[] = $location[$field];
+
+  if (($location['street'] == '') && ($location['city'] == '') && ($location['province'] == '')) {
+    foreach (array('latitude', 'longitude') as $field) {
+      if (isset($location[$field])) {
+        $query_params[] = $location[$field];
+      }
+    }
+  }
+  else {
+    foreach (array('street', 'city', 'province', 'postal_code', 'country') as $field) {
+      if (isset($location[$field])) {
+        $query_params[] = $location[$field];
+      }
     }
   }
   
@@ -162,26 +182,45 @@ function location_map_link_us_google($lo
 }
 
 function location_map_link_us_mapquest($location = array()) {
-  if (isset($location['street'])) {
-    $get_query .= 'address='. urlencode($location['street']) .'&amp;';
+  if (($location['street'] == '') && ($location['city'] == '') && ($location['province'] == '')) {
+    if (isset($location['latitude'])) {
+      $get_query .= 'latitude='. urlencode($location['latitude']) .'&amp;';
+    }
+
+    if (isset($location['longitude'])) {
+      $get_query .= 'longitude='. urlencode($location['longitude']);
+    }
+
+    if (strlen($get_query)) {
+      return 'http://www.mapquest.com/maps/map.adp?searchtype=address&amp;country=US&amp;formtype=latlong&amp;latlongtype=decimal&amp;'. $get_query;
+    }
+    else {
+      return NULL;
+    }
   }
+  else {
+    if (isset($location['street'])) {
+      $get_query .= 'address='. urlencode($location['street']) .'&amp;';
+    }
   
-  if (isset($location['city'])) {
-    $get_query .= 'city='. urlencode($location['city']) .'&amp;';
-  }
+    if (isset($location['city'])) {
+      $get_query .= 'city='. urlencode($location['city']) .'&amp;';
+    }
   
-  if (isset($location['province'])) {
-    $get_query .= 'state='. urlencode($location['province']) .'&amp;';
-  }
+    if (isset($location['province'])) {
+      $get_query .= 'state='. urlencode($location['province']) .'&amp;';
+    }
   
-  if (isset($location['postal_code'])) {
-    $get_query .= 'zipcode='. urlencode($location['postal_code']);
-  }
-  if (strlen($get_query)) {
-    return 'http://www.mapquest.com/maps/map.adp?searchtype=address&amp;country=US&amp;'. $get_query;
-  }
-  else {
-    return NULL;
+    if (isset($location['postal_code'])) {
+      $get_query .= 'zipcode='. urlencode($location['postal_code']);
+    }
+
+    if (strlen($get_query)) {
+      return 'http://www.mapquest.com/maps/map.adp?searchtype=address&amp;country=US&amp;'. $get_query;
+    }
+    else {
+      return NULL;
+    }
   }
 }
 
