I'm really questioning my sanity here and hoping someone can help.
Querying the google maps distance matrix with 2 elements works fine (1 origin, 2 destinations):
$ curl "https://maps.googleapis.com/maps/api/distancematrix/json?origins=Seattle&destinations=Victoria+BC|San+Francisco&key=$GOOGLE_MAPS_API_KEY"
With 3 or more elements, I always get an OVER_QUERY_LIMIT error:
$ curl "https://maps.googleapis.com/maps/api/distancematrix/json?origins=Seattle&destinations=Victoria+BC|San+Francisco|New+York&key=$GOOGLE_MAPS_API_KEY"
{
"destination_addresses" : [],
"error_message" : "You have exceeded your rate-limit for this API.",
"origin_addresses" : [],
"rows" : [],
"status" : "OVER_QUERY_LIMIT"
}
Based on the standard usage limits (pasted below), I shouldn't see this error with a single request of only 3 elements (1 origin and 3 destinations).
Each query sent to the Google Maps Distance Matrix API is limited by the number of allowed elements, where the number of origins times the number of destinations defines the number of elements.
- 2,500 free elements per day, calculated as the sum of client-side and server-side queries.
- Maximum of 25 origins or 25 destinations per request.
- 100 elements per request.
- 100 elements per second, calculated as the sum of client-side and server-side queries.
The pattern holds regardless of the order of the 2 queries. The 2-element query always succeeds and the 3-element query always fails. Any ideas?
Edit: Just tried this with 3 origins and 1 destination with the same result, so it definitely seems to be related to the number of elements in a request.