3

I understand that Google caps requests to 2,500 per day... but there's no way on EARTH that I've made that many requests today, and I just keep getting 'OVER_QUERY_LIMIT'

$street_no = get_post_meta($prop->ID, 'street_no', true);
$street = get_post_meta($prop->ID, 'street', true);
$street_suffix = get_post_meta($prop->ID, 'street_suffix', true);

$addr = urlencode( $street_no." ".$street." ".$street_suffix." BC Canada" );
$url = 'http://maps.googleapis.com/maps/api/geocode/json?address='.$addr.'&sensor=true';
$json_result = json_decode(file_get_contents($url));

if ( $json_result->status === "OVER_QUERY_LIMIT" ) :
    sleep(2);
    $json_result = json_decode(file_get_contents($url));
endif;

As you can see, if I get the status of OVER_QUERY_LIMIT I tell the script to sleep for 2 seconds and then continue on... which seemed to work at some point this morning, but now I just can't even get a single address geocoded.

I'm at a loss as to what to do at this point... it makes my application utterly useless.

dcolumbus
  • 9,596
  • 26
  • 100
  • 165
  • Where are the requests being made from? Your server? Your desktop? Your cell phone? Your shared host on rackspace.com? – geocodezip Feb 08 '13 at 23:00
  • The request is being made from Cloud Sites on rackspace, yes. Which, as I started typing this, it started to make sense that there might be others on the same IP that are querying the geocode api. – dcolumbus Feb 08 '13 at 23:08

5 Answers5

5

Maybe you are sending too many queries per second?

Check out this thread:

OVER_QUERY_LIMIT while using google maps

Community
  • 1
  • 1
Forhad Ahmed
  • 1,761
  • 13
  • 18
4

The quota is shared among all the users of the shared IP, so other sites on the same shared IP must be using the Google Geocoder.

See this thread in the Google Maps API v2 group for more information.

BTW - rackspace was a guess...

A workaround would be to use client based geocoding, but verify your use complies with the terms of use.

The webservice now supports a key, another option is to use a key in your request so you get your own quota.

geocodezip
  • 158,664
  • 13
  • 220
  • 245
1

I faced a similar issue to this with my heroku hosted java application. The way I got around it was to set up a micro EC2 instance and install Dante on it to run as a proxy server. Then I just route my gecoding requests through the proxy and can make the full 2,000 requests per day. Obviously it's worth caching results to minimise the api calls too. The EC2 instance is free for the first year and after that still not that expensive and you can always use it for more than just Dante.

I've written details of how I set this up here: Using Google geocoding from Heroku

Joe Pugh
  • 31
  • 1
  • 3
0

I have the same problem making calls to the geocoding REST interface from a server on Heroku (hosted on Amazon EC2)

This could be fixed if I could use my Maps API key in the request and they tracked the number of calls per api key.

I agree that this is a serious problem...

Bing, MapQuest and others have free geocoding APIs - you (and I) should look at those.

craic.com
  • 3,786
  • 5
  • 22
  • 17
0

You can use a hosted proxy service like QuotaGuard which will stop your requests coming from a shared IP so you don't get blocked by Google when using Rackspace/Heroku etc.

Tim Williams
  • 318
  • 2
  • 6