If the user only selected a country geoding was not working for me. Therefore I set "$q" to countrycode if empty.

I added a small fix to geocoding/google.inc in "google_geocode_location".

$q = _google_geocode_flatten($location);
 
if(empty($q)) {
$q = $location['country'];
}

$query = array(
    'key' => $key,
    'sensor' => 'false', // Required by TOS.
    'output' => 'xml',
    //'ll' => 0,
    //'spn' => 0,
    'gl' => $location['country'],
    'q' => $q, // $q goes here
  );

Patch attached.

Comments

animelion’s picture

Status:Active» Needs review

Lets get this committed

rooby’s picture

Title:Google Geocoding fix» Country is not added to address when using google geocoding
StatusFileSize
new1.36 KB

Instead of checking the address after the call to _google_geocode_flatten() we should probably fix _google_geocode_flatten() itself.

This patch changes _google_geocode_flatten() to make it add the country to the address.
I also snuck in a little bit of code cleanup.

Can you test my patch for your use case?

The patch is against current cvs dev. Should apply to current dev download too.
Or you can manually apply to the 3.1 release if it doesn't apply cleanly.

Agileware’s picture

The patch in #2 works for me.

My use case is the user enters just a country and no other details and the coords are geocoded from that.

havran’s picture

Patch #2 work for me too.

juliusvaart’s picture

Patch #2 works for me too.

Status:Fixed» Closed (fixed)
Issue tags:-geocode

Automatically closed -- issue fixed for 2 weeks with no activity.