--- location.inc 2010-07-04 15:10:07.000000000 +0100 +++ locationNew.inc 2010-10-01 18:19:02.000000000 +0100 @@ -45,12 +45,15 @@ function location_map_link($location = a $default_func = 'location_map_link_'. $location['country'] .'_default_providers'; $providers_func = 'location_map_link_'. $location['country'] .'_providers'; - $providers = function_exists($providers_func) ? $providers_func() : array(); - $selected_providers = variable_get('location_map_link_'. $location['country'], function_exists($default_func) ? $default_func() : array()); + $providers = function_exists($providers_func) ? $providers_func() : location_map_link_none_providers(); + $selected_providers = variable_get('location_map_link_'. $location['country'], function_exists($default_func) ? $default_func() : location_map_link_none_default_providers()); $links = array(); foreach ($selected_providers as $mapper) { $link_func = 'location_map_link_'. $location['country'] .'_'. $mapper; + if (!function_exists($link_func)) { + $link_func = ('location_map_link_none_'. $mapper); + } if (function_exists($link_func)) { if ($link = $link_func($location)) { $links[] = ''. $providers[$mapper]['name'] .''; @@ -65,6 +68,45 @@ function location_map_link($location = a } } +function location_map_link_none_providers() { + return array( + 'google' => array( + 'name' => 'Google Maps', + 'url' => 'http://maps.google.com', + 'tos' => 'http://www.google.com/help/terms_maps.html', + ), + ); +} + +function location_map_link_none_default_providers() { + return array('google'); +} + +function location_map_link_none_google($location = array()) { + + $query_params = array(); + + foreach (array('name', 'street', 'additional', 'city', 'postal_code', 'country') as $field) { + if (isset($location[$field])) { + $query_params[] = $location[$field]; + } + } + + if (location_has_coordinates($location)) { + $q = urlencode($location['latitude'] . ' ' . $location['longitude'] . ' (' . implode(', ', $query_params) . ')' ); + } else if (count($query_params) > 0) { + $q = urlencode(implode(", ", $query_params)); + } + + if ($q != NULL) { + return ('http://maps.google.com?q='.$q ); + } + + else { + return NULL; + } +} + /** * Try to extract the the Latitude and Longitude data from the * postal code.