I am using your api in my application for several functionalities namely,
— Get directions to a destination
— Get distances to several locations
— Receive location addresses by locating with markers on the map
Application summary (Local-Deals-Now)
The application is a free application to allow local businesses located in Australia, to publish offers/deals related to their business. A user can create a business account (free of charge) and give the location of their business (using google maps api) and add offers/deals to the system by dates and times. Public users/consumers can then view these offers (Or search by distance, location, date, keywords etc:-…. The distance to the offers from the current user location is calculated using distancematrix api).
The application stated above is currently in its development stages and can be accessed via http://www.chuli.fclhosting.com/ . The problem faced was when using the distance matrix APIs to calculate distances to the business from the current logged in user location. I am using the API on the server side as follows
$curl = curl_init();
$uri = "http://maps.googleapis.com/maps/api/distancematrix/json?origins=".$originString."&destinations=".$destinationsString."&mode=driving&language&sensor=false";
die($uri);
$options = array(
CURLOPT_URL => $uri,
CURLOPT_HTTPHEADER => array(),
CURLOPT_COOKIE => '',
CURLOPT_RETURNTRANSFER => true
);
curl_setopt_array($curl, $options);
$responseBody = curl_exec($curl);
$responseHeaders = curl_getinfo($curl);
$data = $responseBody;
$responseContentType = $responseHeaders['content_type'];
if ((strpos($responseContentType, 'json') !== false) || (substr(html_entity_decode(trim($data)), 0, 1) == "{")) {
$jsonData = json_decode($data, true);
if (!is_null($jsonData)) {
$data =$jsonData;
}
}
for ($i = 0; $i < count($data['origin_addresses']); $i++) {
for ($j = 0; $j < count($data['destination_addresses']); $j++) {
$from = $data['origin_addresses'][$i];
$to = $data['destination_addresses'][$j];
if($data['rows'][$i]['elements'][$j]['status']=="OK" && $data['rows'][$i]['elements'][$j]['distance']['value']<= ($distance*1000)) {
$businessDistanceArray[$businesses[$j]->getId()] = $data['rows'][$i]['elements'][$j]['distance']['text'];
} else {
$businessDistanceArray[$businesses[$j]->getId()] = sfConfig::get('app_offer_not_applicable');
}
}
}
Since recently i have started receiving a warning/error stating OVER_QUERY_LIMIT. After googling on the problem (reference : https://developers.google.com/maps/documentation/javascript/usage) i have grasped that , the above problem occurs either if
–the request limit per day exceeds 25 000 map loads
OR
–by sending too many requests per second
The application as to my knowledge doe not fulfill either one of the above requirements but, still received the warning. Please let me know what i could do regarding this problem in order to overcome this error
Do i have to purchase a business license
OR
Since currently the application is a non profitable one should i apply for a Google Earth Outeach Grant
OR
Just continue without any changes
Here is a sample request sent:
http://maps.google.com/maps/api/distancematrix/json?origins=-25.198526444487587,133.20029780312507&destinations=-33.767636351789754,147.41606950000005|-33.905755787445024,151.15402221679688|-32.02195365825273,115.90862329062497|-37.79805567326585,145.01495173583987|-36.8839206402564,144.20859858437507|-31.362071510290537,117.42054612812501|-23.609959,143.72078599999998|-37.819317,145.12404889999993|-37.8186394,145.12360620000004|-37.816506,145.11867699999993|-37.815524,145.12131499999998|-30.708111,134.56642599999998&mode=driving&language&sensor=false
Please look into the info given above. Your feedback would thoroughly appreciated by us
Thanks in advance
There are two different limits like Dr.Molle says. You exceeded the daily limit which allows 2500 elements to be queried in a 24 hour period of time. When this happens you’ll get continuous OVER_QUERY_LIMIT errors until that 24 hour time window expires and your quota refreshes.
The other limit to be on the lookout for is the short term limit of 100 elements every 10 seconds. When you exceed this limit you’ll experience the OVER_QUERY_LIMIT error for a few seconds (i.e. until the 10 second window is up) and then you’ll be able to use the service again.
If this is a user-facing application that loads the Google Maps JavaScript API and performs these distance matrix queries as a result of some user action the JavaScript Distance Matrix Service is definitely worth exploring. Limits from the JavaScript application are distributed among your website users, not the back-end server.