Hello,
Following the Google Geocoding API v2 deprecation, it seems impossible to use geocoding in a location field, which means longitude and latitude won't be calculated when a node's location is updated. Here's the notice in the log :

Google geocoding returned status code: 610

It is caused by the XML response :

<?xml version="1.0" encoding="UTF-8" ?>
<kml xmlns="http://earth.google.com/kml/2.0"><Response>
  <Status>
    <errorcode>610</errorcode>
    <request>geocode</request>
  </Status>
</Response></kml>

The status code 610 corresponds to a bad api key, but I double checked it, mine was working last week and works for everything but geocoding, I tried the same request on my side, with other api keys, but still receive status code 610.
Same API key with an API V3 request works fine, but the XML response is not compatible with the module.
I had a look at the location/geocoding/google.inc file, where the api http request is done : from line 112. There is no API V3 support.
So the API migration will have to be developed unless we find an alternative until 8 September 2013.

Could someone confirm the issue ?
Thanks in advance.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Azzar’s picture

I can confirm that the geocoding on the site I'm developing stopped working March 8th.
I have to launch the site tomorrow, so for now I managed to make it work with a quick'n'dirty hack in location/geocoding/google.inc

bfranco’s picture

Version: 7.x-3.0-alpha3 » 7.x-3.0-alpha1
FileSize
2.98 KB

I noticed this and tried to come up with a solution. As stated, V2 of the API is abandoned, so we need to use V3. It doesn't need drastic changes. I attached a patch, this is how it works over here. I also switched to using json, because parsing xml with regex is a bit silly imo. Don't shoot me if it's not perfect or solutions are posted elsewhere, I'm only a Drupal development intern. ;)

leban’s picture

Version: 7.x-3.0-alpha1 » 7.x-3.0-alpha3

Would you care to tell us about your hack? I need to it get back to working quick as well...

shashikant_chauhan’s picture

I am also getting Google geocoding returned status code: 610

leban’s picture

Version: 7.x-3.0-alpha1 » 7.x-3.0-alpha3

Tried the patch...

Notice: Undefined offset: 0 in google_geocode_location() (line 142 of /var/sites/f/foretagssidan.fi/public_html/sites/all/modules/location/geocoding/google.inc).
Notice: Trying to get property of non-object in google_geocode_location() (line 142 of /var/sites/f/foretagssidan.fi/public_html/sites/all/modules/location/geocoding/google.inc).
Notice: Trying to get property of non-object in google_geocode_location() (line 142 of /var/sites/f/foretagssidan.fi/public_html/sites/all/modules/location/geocoding/google.inc).

offending line looks like this:

  $location = $data->results[0]->geometry->location;

From Drupal log I noticed the following return code from Google:

Google geocoding returned status code: OVER_QUERY_LIMIT

bfranco’s picture

Simple, the url needs to be http://maps.googleapis.com/maps/api/geocode/json (or http://maps.googleapis.com/maps/api/geocode/xml depending on what you want). I've thrown out the key of the query because it's not needed.

After doing $http_reply = drupal_http_request($url);

I use the data like this:

$data = json_decode($http_reply->data);

$location = $data->results[0]->geometry->location;

$status_code = $data->status;

The location now is an object with 2 members, 'lat' and 'lng' which are the geocoded coordinates, so the return for google_geocode_location() should be array('lat' => $location->lat, 'lon' => $location->lng);
The status code appears to be a string like 'OK' instead of numerical error codes.

I also removed the comma's in the constructed string in _google_geocode_flatten(), it screws things up due to url encoding (over here at least).

I haven't fully tested it, but it seems to be working.

@ leban, that's probably because it's not returning a geocoded location, so the result is empty. The status code test should be performed before the line of code that's generating the error. It needs some error handling. The patch isn't a ready to go solution, it's just to show a way.

manoloka’s picture

Version: 7.x-3.0-alpha3 » 7.x-3.0-alpha1

I have an issue since Sunday the 10th of March that may be related to this.

I use a "search by postcode proximity" list, that order a list results by proximity, that stopped working on Sunday for any new postcode (meaning not used before) searched for.

I'm getting a location log entry - Google geocoding returned status code: 610

Any way to make this work?

wellsys_world’s picture

Version: 7.x-3.0-alpha1 » 7.x-3.0-alpha3

We've applied the patch in #2 and following some testing pushed out to a production site.

Our users' new postcode searches (Views proximity exposed filter) are being added to the zipcodes table.

Seems to have fixed the issue!

Thanks @bfranco

integrateurxhtm’s picture

The patch #2 worked for me,
To avoid errors of #5, you have to move the $location line under the status_code test.
You'll get something like that

  $status_code = $data->status;
  if ($status_code != 'OK') {
    watchdog('location', 'Google geocoding returned status code: %status_code', array('%status_code' => $data->status));
     return NULL;
   }
  $location = $data->results[0]->geometry->location;
manoloka’s picture

Version: 7.x-3.0-alpha3 » 7.x-3.0-alpha1

Will this patch work for drupal 6? will this be ported to drupal 6?

I'm not programmer but I'd be happy to chip something in to get this sorted for drupal 6 too.

Thanks

podarok’s picture

Version: 7.x-3.0-alpha1 » 7.x-3.x-dev
Status: Active » Needs review

lets test it )

podarok’s picture

#9 can You create a full patch against latest dev?

Status: Needs review » Needs work

The last submitted patch, location_geocode_v3.patch, failed testing.

mikavirt’s picture

Patch of post #2 and comment #9 solved the issue for me, thank you!

leban’s picture

Applied patch of #2 but now I don't get 610 any more but...

Google geocoding returned status code: OVER_QUERY_LIMIT

Oddly its not same as 620, DOS. Any ideas?

podarok’s picture

leban’s picture

Status: Needs work » Needs review

#2: location_geocode_v3.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, location_geocode_v3.patch, failed testing.

podarok’s picture

looks like the patch #2 needs reroll against latest 7.x-3.x-dev

manoloka’s picture

I can confirm that patch of post #2 and comment #9 solved the issue for me ... and I'm on D6

thank you!

Jerenus’s picture

Status: Needs work » Needs review
FileSize
3.41 KB

Here is the patch. It works for me.

podarok’s picture

Status: Needs review » Fixed

#21 commited pushed to 7.x-3.x
will be tagged in next minor release update

Thanks!!!!

podarok’s picture

http://drupal.org/node/1942736 tagged in alpha release

Jerenus’s picture

Great!

LeDucDuBleuet’s picture

Status: Fixed » Needs work

Thank you all for your time, it is great to see the Drupal community at work!

While it is true that this patch works, I believe it needs more work.

In the committed patch, I don't see why we removed the line :

- $delay_trigger = TRUE;

If we remove it, the first few lines in google_geocode_location that introduce a delay between consecutive requests will not work and this is important as stated in the Google geocode option page :
To avoid a 620 error (denial of service) from Google, you can add a delay between geocoding requests. 200ms is recommended.

In v3, the returned status will not be 620 but they are still enforcing a request rate limit.

Also, I believe the parameter for the country 'gl' should be rename 'region' as per the v3 spec :
https://developers.google.com/maps/documentation/geocoding/

And if we specify the country in the 'region' parameter, I don't think we should include it again in the 'address' parameter in the function _google_geocode_flatten since it may lead to incorrect response. For example, if the country is Canada (CA) and I make a request with only the country in the location, it will return a location in California which is not what we wanted.

Also, I don't see why we dropped the commas in the 'address' parameter, while it may work without them, it is in the spec as outlined in the example for JSON output format :
http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheat...

Also, if we remove the key from the request why do we keep the code that gets it ?

This comment is way longer than I had expected but I believe it is important, thanks again for your time!

podarok’s picture

can You provide a follow-up patch for that?

LeDucDuBleuet’s picture

Status: Needs work » Needs review
FileSize
2.08 KB

Sure, here it is!

I let the country in the address since someone might want the approximate lat/long for a country and if we only specify it with the region parameter and not in the address, we get a ZERO_RESULTS status instead of coordinates.

I also added the url in the watchdog entry for debugging purposes.

podarok’s picture

Status: Needs review » Fixed

##2 nice
Looks good

commited and pushed to 7.x-3.x
thanks!!!

Jerenus’s picture

I felt a great harvest, thank you very much.

skulegirl’s picture

A huge enormous THANK YOU to the amazing drupal community for geting a patch up for this so quickly. I discovered this issue this afternoon and was freaking out thinking I'd be up all night trying to fix it. You've given me the gift of sleep!

Lalith’s picture

Thank you verymuch @Jerenus for your patch. I am working on D6 and I couldn't able to apply patch directly on the file which I am having, seems there is a version difference. But I managed to make changes to my file based on your patch and it rocked :)
The module which I am using was worked till recent dates but suddenly it stopped working. I want to understand why this happens? Can someone clarify this?

geekmuse’s picture

I just wanted to confirm @manoloka's posting that the patch(es) he mentioned did indeed get this working again. I thought I'd provide a 6.x-3.x patch for anyone who wanted a simplified way to fix this on 6.x installs. I was hesitant to change the issue status since this is a 6.x patch and this thread is for the 7.x branch, but testing out on 6.x installs would definitely be helpful to verify that I did this correctly :)

podarok’s picture

Status: Fixed » Needs review

bot?

Status: Needs review » Needs work

The last submitted patch, fixGoogle610ApiError-1940474-32.patch, failed testing.

podarok’s picture

patch needs reroll

LeDucDuBleuet’s picture

Version: 7.x-3.x-dev » 6.x-3.x-dev
Status: Needs work » Needs review
FileSize
3.01 KB

Here is the patch for d6 based on latest dev, it is the same as the one in comment #27.
It is introducing the delay trigger to avoid going over limit with the Google API same as D7.
This patch removes the accuracy filtering for now same as D7, maybe we could introduce it back later?
Enjoy!

Status: Needs review » Needs work

The last submitted patch, gmapv3code610d6-1940474-36.patch, failed testing.

LeDucDuBleuet’s picture

Status: Needs work » Needs review
FileSize
3.6 KB

The last submitted patch failed because the result is not exactly the same with the v3 API.
It now returns 37.4218378, -122.0846263 instead of 37.421972, -122.084143
I rerolled the patch with the new expected results in LocationGoogleGeocoderTest->testUSA()

Status: Needs review » Needs work

The last submitted patch, gmapv3code610d6-1940474-38.patch, failed testing.

LeDucDuBleuet’s picture

Oups, sorry, the error is caused by the delay trigger feature so I removed it.
Here is the re-rolled patch, sorry about the multiple submissions, it should pass now!

LeDucDuBleuet’s picture

Status: Needs work » Needs review

Changing the status for the bot...

podarok’s picture

Status: Needs review » Fixed

#41 looks good
commited pushed to 6.x-3.x
thanks!!!!

podarok’s picture

http://drupal.org/node/1952436 tagged beta2 release

Status: Fixed » Closed (fixed)

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

thomas@explose.lu’s picture

Priority: Critical » Normal

Just wanted to say thanks a lot for the quick fix! it works great.

Sylvain_G’s picture

#40 works for me with some adaptations on 6.x-3.2

szy’s picture

Is everything all right with beta3?

The patch looks like applied to google.inc, but I still
get 'ZERO RESULTS' for addresses in Poland.

What about you, guys?

Szy.

ducdebreme’s picture

Just upgraded to location-6.x-3.x-dev and it fixed the problem.
I think, you should create a new release, which includes fix - the official release is unuseful.

pebosi’s picture

Status: Closed (fixed) » Active

#48 is right, geocoding is not working on 3.3, patch attaching...

pebosi’s picture

FileSize
2.49 KB

Patch removes "component" from api query, as it is not needed and query will show "ZERO _RESULTS". Also the api key settings form is removed, there is no need to add a key.

pebosi’s picture

Status: Active » Needs review
crystaldawn’s picture

Call me crazy but I dont see these patches in either the Stable OR dev branches for 7.x Where is the issue queue entry for the 7.x branch for this problem. The geocoding features are completely useless without these patches now that V2 has been completely depreciated and removed from existence. It's time to move on in the world :P. They work fine when I add them in by hand, but this shouldnt be necessary since they have been tested for some time now.

UPDATE: This was a drush issue. For whatever reason, no matter what I did, drush kept getting a version that did not have this issue fixed. I ended up having to DL/install it manually.

podarok’s picture

Status: Needs review » Fixed

#50 commited pushed to 6.x-3.x
Thanks!

Status: Fixed » Closed (fixed)

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

funkycamel queued 27: 1940474.patch for re-testing.

The last submitted patch, 27: 1940474.patch, failed testing.