1
votes

I' using the following script in google sheets:

function reverseGeocode(addressType, lat, lng) {
Utilities.sleep(1500);
if (typeof addressType != 'string') {
    throw new Error("addressType should be a string.");
}

if (typeof lat != 'number') {
    throw new Error("lat should be a number");
}

if (typeof lng != 'number') {
    throw new Error("lng should be a number");
}
var response = Maps.newGeocoder().reverseGeocode(lat, lng),
    key      = '';
response.results.some(function (result) {
    result.address_components.some(function (address_component) {
        return address_component.types.some(function (type) {
            if (type == addressType) {
                key = address_component.long_name;
                return true;
            }
        });
    });
});
return key;}

and I get the error: Service invoked too many times for one day: geocode. (line 24) Does somebody know the solution?

1
Pay for the service instead of using the free version? You get 2500 requests per day for free - how many are you making?stdunbar
Keys are required (now), how are you entering yours? Are you using a real key?geocodezip
please do minimal research before posting here. the error itself says what's wrong and a trivial googling would find the answer.Zig Mandel
@stdunbar This is when you use a key. Would you mind telling how to add key in above script?Umair
@Umair The key isn't added in the above code (it isn't complete). It needs to be added to the request to the service.geocodezip

1 Answers

0
votes

If a script reaches a quota or limitation, it will throw an exception with a message similar to your error. This indicates that the script called the given service too many times in one day.

You may review the usage limits page for details on the quotas set for the Google Maps Geocoding API. As @ stdunbar stated, you have 2,500 free requests per day and if you exceed the per-day limit or otherwise abuse the service, the Google Maps Geocoding API may stop working for you temporarily. If you continue to exceed this limit, your access to the Google Maps Geocoding API may be blocked.

You may check these threads for reference: