Download & Extend

Country is not added to address when using google geocoding

Project:Location
Version:6.x-3.1
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)
Issue tags:geocode

Issue Summary

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.

AttachmentSizeStatusTest resultOperations
0-geocoding_google-6.x.3.1.patch203 bytesIgnored: Check issue status.NoneNone

Comments

#1

Status:active» needs review

Lets get this committed

#2

Title:Google Geocoding fix» Country is not added to address when using google geocoding

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.

AttachmentSizeStatusTest resultOperations
location-google_geocode_flatten-907564-2.patch1.36 KBIgnored: Check issue status.NoneNone

#3

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.

#4

Patch #2 work for me too.

#5

Patch #2 works for me too.

#7

Status:fixed» closed (fixed)

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

nobody click here