Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#2 | location-google_geocode_flatten-907564-2.patch | 1.36 KB | rooby |
0-geocoding_google-6.x.3.1.patch | 203 bytes | naden | |
Comments
Comment #1
bryancasler CreditAttribution: bryancasler commentedLets get this committed
Comment #2
rooby CreditAttribution: rooby commentedInstead 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.
Comment #3
Agileware CreditAttribution: Agileware commentedThe 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.
Comment #4
havran CreditAttribution: havran commentedPatch #2 work for me too.
Comment #5
juliusvaart CreditAttribution: juliusvaart commentedPatch #2 works for me too.
Comment #6
rooby CreditAttribution: rooby commentedThanks for reviewing.
Committed to all versions.
http://drupalcode.org/project/location.git/commit/8c8ce88
http://drupalcode.org/project/location.git/commit/293dcd8
http://drupalcode.org/project/location.git/commit/2e563cf
http://drupalcode.org/project/location.git/commit/9f75ca6