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.

Files: 
CommentFileSizeAuthor
#50 fix-geocoder-1940474.patch2.49 KBpebosi
PASSED: [[SimpleTest]]: [MySQL] 329 pass(es).
[ View ]
#40 gmapv3code610d6-1940474-40.patch3.4 KBLeDucDuBleuet
PASSED: [[SimpleTest]]: [MySQL] 329 pass(es).
[ View ]
#38 gmapv3code610d6-1940474-38.patch3.6 KBLeDucDuBleuet
FAILED: [[SimpleTest]]: [MySQL] 329 pass(es), 1 fail(s), and 0 exception(s).
[ View ]
#36 gmapv3code610d6-1940474-36.patch3.01 KBLeDucDuBleuet
FAILED: [[SimpleTest]]: [MySQL] 329 pass(es), 1 fail(s), and 0 exception(s).
[ View ]
#32 fixGoogle610ApiError-1940474-32.patch3.01 KBgeekmuse
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch fixGoogle610ApiError-1940474-32.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#27 1940474.patch2.08 KBLeDucDuBleuet
PASSED: [[SimpleTest]]: [MySQL] 425 pass(es).
[ View ]
#21 location-geocode_update_to_v3-1940474-21.patch3.41 KBJerenus
PASSED: [[SimpleTest]]: [MySQL] 425 pass(es).
[ View ]
#2 location_geocode_v3.patch2.98 KBbfranco
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch location_geocode_v3.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Comments

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

Version:7.x-3.0-alpha3» 7.x-3.0-alpha1
StatusFileSize
new2.98 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch location_geocode_v3.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

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. ;)

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...

I am also getting Google geocoding returned status code: 610

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:

<?php
  $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

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.

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?

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

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

<?php
  $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;
?>

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

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

lets test it )

#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.

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

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?

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.

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

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

thank you!

Status:Needs work» Needs review
StatusFileSize
new3.41 KB
PASSED: [[SimpleTest]]: [MySQL] 425 pass(es).
[ View ]

Here is the patch. It works for me.

Status:Needs review» Fixed

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

Thanks!!!!

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

Great!

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!

can You provide a follow-up patch for that?

Status:Needs work» Needs review
StatusFileSize
new2.08 KB
PASSED: [[SimpleTest]]: [MySQL] 425 pass(es).
[ View ]

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.

Status:Needs review» Fixed

##2 nice
Looks good

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

I felt a great harvest, thank you very much.

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!

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?

StatusFileSize
new3.01 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch fixGoogle610ApiError-1940474-32.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

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 :)

Status:Fixed» Needs review

bot?

Status:Needs review» Needs work

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

patch needs reroll

Version:7.x-3.x-dev» 6.x-3.x-dev
Status:Needs work» Needs review
StatusFileSize
new3.01 KB
FAILED: [[SimpleTest]]: [MySQL] 329 pass(es), 1 fail(s), and 0 exception(s).
[ View ]

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.

Status:Needs work» Needs review
StatusFileSize
new3.6 KB
FAILED: [[SimpleTest]]: [MySQL] 329 pass(es), 1 fail(s), and 0 exception(s).
[ View ]

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.

StatusFileSize
new3.4 KB
PASSED: [[SimpleTest]]: [MySQL] 329 pass(es).
[ View ]

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!

Status:Needs work» Needs review

Changing the status for the bot...

Status:Needs review» Fixed

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

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

Status:Fixed» Closed (fixed)

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

Priority:Critical» Normal

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

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

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.

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.

Status:Closed (fixed)» Active

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

StatusFileSize
new2.49 KB
PASSED: [[SimpleTest]]: [MySQL] 329 pass(es).
[ View ]

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.

Status:Active» Needs review

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.

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.