Map showing error "Geocode was not successful for the following reason: OVER_QUERY_LIMIT"

4,325 views
Skip to first unread message

Rahul Gohate

unread,
Oct 7, 2013, 6:12:26 AM10/7/13
to google-map...@googlegroups.com
Hi,

I am using Google Map API v3. I got error "Geocode was not successful for the following reason: OVER_QUERY_LIMIT" when I try to display markers on map. 11 markers are shown properly on Map but not more that that. Please help me to solve this error. My Code is 

function initialize() {
//alert("hi");
  geocoder = new google.maps.Geocoder();
  <?php
  $sql="select meta_value from wp_postmeta where meta_key='_alkurn_distributor_address'";
  $res=mysql_query($sql);
  while($row=mysql_fetch_array($res))
  {
  ?>
  var address="<?php echo $row['meta_value'];?>";
    geocoder = new google.maps.Geocoder();
    var lat='';
    var lng=''
    geocoder.geocode( { 'address': address}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {
       lat = results[0].geometry.location.lat(); //getting the lat
       lng = results[0].geometry.location.lng(); //getting the lng
       map.setCenter(results[0].geometry.location);
  
 var marker = new google.maps.Marker({
           map: map,
  position: results[0].geometry.location
       });
    
  
     } else {
            console.log("Geocode was not successful for the following reason: " + status);
            }
     });
<?php } ?>
  var chicago = new google.maps.LatLng(36.4278,-15.9);
  var myOptions = {
    zoom: 2,
    center: chicago,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }

  map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
  google.maps.event.addListener(map, "click", function() {
    document.getElementById('info').innerHTML = "";
  });


  kmlLayer = new google.maps.KmlLayer('http://www.geocodezip.com/geoxml3_test/world_countries_kml.xml', {preserveViewport: true, suppressInfoWindows: true} );
  kmlLayer.setMap(map);

  google.maps.event.addListener(kmlLayer, 'click', openIW);

}


Please help me to solve my error.

Thank You

Rahul

Barry Hunter

unread,
Oct 10, 2013, 10:07:42 PM10/10/13
to google-maps-js-api-v3
 I got error "Geocode was not successful for the following reason: OVER_QUERY_LIMIT" when I try to display markers on map. 

Isnt that kinda self explanority. You've made too many queries! There is a quota, its not unlimited use. 

You need to reduce your limit. 


You appear to be regeocding the same locations each time the page is loaded. That's not only a waste of resources, its slow for the user, and it eats quota. 

Instead you should geocode the location ONCE, and save the lat/long in your database for reuse. Kinda like caching. There is a seperate HTTP geocoder you can use server side, or you can still do it client side. If you have a location in the database for a point, use it. If not, use the geocoder as you have now, then use AJAX style request to submit the location back to the server. That way the next request doesnt need to use geocoding quota. 


(actully not just once, should set the location to expire, say every 60 days, so it is regeocoded from time to time. To allow for corrections to the database) 



 
Reply all
Reply to author
Forward
0 new messages