summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--geocoding/google.inc46
1 files changed, 32 insertions, 14 deletions
diff --git a/geocoding/google.inc b/geocoding/google.inc
index 2d185a3..1008eb2 100644
--- a/geocoding/google.inc
+++ b/geocoding/google.inc
@@ -6,8 +6,17 @@ function google_geocode_country_list() {
if (!count($countries)) {
$countries = array(
+ 'br',
'ca',
+ 'cz',
+ 'de',
'fr',
+ 'hu',
+ 'in',
+ 'pl',
+ 'pt',
+ 'sg',
+ 'tw',
'us',
'uk'
);
@@ -28,25 +37,34 @@ function google_geocode_info() {
}
function google_geocode_location($location = array()) {
+
+ switch ($location['country']) {
+ case 'uk':
+ if ($location['street'] && $location['city']) {
+ unset($location['postal_code']);
+ }
+ elseif ($location['postal_code']) {
+ unset($location['city']);
+ unset($location['street']);
+ unset($location['additional']);
+ }
+ else {
+ unset($location['postal_code']);
+ }
+ $query = location_address2singleline($location);
+ break;
+ default:
+ $query = location_address2singleline($location);
+ break;
+ }
+
if ($location['country'] == 'uk') {
- if ($location['street'] && $location['city']) {
- unset($location['postal_code']);
- }
- elseif ($location['postal_code']) {
- unset($location['city']);
- unset($location['street']);
- unset($location['additional']);
- }
- else {
- unset($location['postal_code']);
- }
+
}
$service_url = 'http://maps.google.com/maps/geo?output=xml&key='. variable_get('location_geocode_google_apikey', '') .'&q=';
-
- $address = location_address2singleline($location);
- $http_reply = drupal_http_request($service_url . urlencode($address));
+ $http_reply = drupal_http_request($service_url . urlencode($query));
$status_code_match = array();
preg_match('/<code>(.*)<\/code>/', $http_reply->data, $status_code_match);