Reputation: 191
I'm using the geocoding API on the server side to translate addresses in latlng. I faced a OVER_QUERY_LIMIT status even though : - the server didn't exceed the 2500 limitation (just a few request on this day) - it didn't do many requests simultaneously (just one single request at a time)
how is that possible ? the next day the geocoding was working well but i'm concerned about my application working correctly in the long run.
Thanks in advance.
Upvotes: 19
Views: 44002
Reputation: 5267
Google, Bing, MapQuest, and Yahoo! Maps (is this API still around?) are extremely powerful tools. They have a lot of horsepower that they put behind interpreting the address you provide and doing everything possible to make it into a properly formatted address for geocoding. To a certain degree they are free. They have volume limits and pretty strict Terms Of Service (TOS) that might be a factor if you start using their service commercially and especially if you integrate it into another product.
Keep in mind that all of them do "address approximation" NOT address verification. They will be able to tell you approximately where an address would lie on a certain street IF the address exists. They cannot tell you that the address you are looking for exists. One way to verify this is to look at your own address in Google Maps. Zoom all the way in to street view and you'll see that they state "address is approximate" even though they may have the location pinpointed exactly. They just don't have the master list of addresses to compare and know which addresses are real. For that, you will need some sort of address verification.
Address verification standardizes and cleans a given address in much the same way as the free mapping services but it also compares the addresses to the USPS database of deliverable addresses to confirm if the address really exists. The confirmed address can then be geocoded with improved accuracy.
There are a lot of good address verification services out there. In the interest of full disclosure, I'm the founder of one--SmartyStreets.
Upvotes: 3
Reputation: 76
Same problem as user276648 here. Solved it by adding the API key and changing http to https.
Upvotes: 1
Reputation: 1484
Google also returns this same response if no address matches were found. It does not necessarily mean you've exceeded the quota. In any case you'll be better off catching the exception and implementing a rescue around it.
Upvotes: 1
Reputation: 4473
This is how I have handled this issue in the past. I check the result status and if I get and over the limit error I try it again after a slight delay.
function Geocode(address) {
geocoder.geocode({
'address': address
}, function(results, status) {
if (status === google.maps.GeocoderStatus.OK) {
var result = results[0].geometry.location;
var marker = new google.maps.Marker({
position: result,
map: map
});
} else if (status === google.maps.GeocoderStatus.OVER_QUERY_LIMIT) {
setTimeout(function() {
Geocode(address);
}, 200);
} else {
alert("Geocode was not successful for the following reason:"
+ status);
}
});
}
Update: whoops, accidentally glossed over the server side part. Here is a C# version:
public XElement GetGeocodingSearchResults(string address)
{
var url = String.Format(
"https://maps.google.com/maps/api/geocode/xml?address={0}&sensor=false",
Uri.EscapeDataString(address));
var results = XElement.Load(url);
// Check the status
var status = results.Element("status").Value;
if(status == "OVER_QUERY_LIMIT")
{
Thread.Sleep(200);
GetGeocodingSearchResults(address);
}else if(status != "OK" && status != "ZERO_RESULTS")
{
// Whoops, something else was wrong with the request...
}
return results;
}
Upvotes: 34
Reputation: 8819
You can also do geocoding on the client side. Here's an article comparing the approach of doing something client side and something server site.
Upvotes: 2
Reputation: 2396
We had this problem as well and the solution was to ditch google's API. If all you need is geocoding there are numerous alternatives that are equally as effective without the limitations. We chose the mapquest API. It has been faster and more reliable with no cap on geocoding calls plus I really like their API for batching together geocoding requests into a single call.
If there are other features you require, obviously you have to take those into consideration, but in the case of a single feature, using the biggest API on the block is not necessarily the best choice.
developer.mapquest.com
Upvotes: 4