Google Maps Geocode Status OVER_QUERY_LIMIT

北战南征 提交于 2020-01-04 13:41:19

问题


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.


回答1:


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.




回答2:


Maybe you are sending too many queries per second?

Check out this thread:

OVER_QUERY_LIMIT while using google maps




回答3:


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




回答4:


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.




回答5:


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.



来源:https://stackoverflow.com/questions/14782496/google-maps-geocode-status-over-query-limit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!