0

So I have a function that takes multiple addresses from a .csv file and converts them to lat and lng using googles geocoding api. Then maps those as markers using google's map api.

I am running into a OVER_QUERY_LIMIT error when I run the function and was wondering if there was any way for me to slow down a function that is built like this?

My Function:

 function codeAddress() {
   var Branch = document.getElementById("mySelect").value;
   for(let row of DeliveryData.rows){

       var location = row.get('Deliver To');
   var address = location;

   geocoder.geocode( { 'address': address}, function(results, status) {
     if (status == 'OK') {
       //console.log(results[0].geometry.location);
       var marker = new google.maps.Marker({
           map: map,
           position: results[0].geometry.location
       });
          var contentString = address;
       var infowindow = new google.maps.InfoWindow({
         content: "Delivery Location: </br>" + address + "</br>Branch: </br>" + Branch
       });
         marker.addListener('click', function() {
         infowindow.open(map, marker);
      });
     } else {
      alert('Geocode was not successful for the following reason: ' + status);
     }
   });
   }
 }
  • https://stackoverflow.com/questions/2419219/how-do-i-geocode-20-addresses-without-receiving-an-over-query-limit-response – Teemu Jun 28 '18 at 14:04
  • This doesn't help me. I have already read this thread. My question is posted above. Thanks. –  Jun 28 '18 at 14:07
  • [No?](https://stackoverflow.com/a/10231661/1169519) – Teemu Jun 28 '18 at 14:09
  • That function is not built in the same way that mine is built. I did research on this before asking the question and could not find an answer, hence why I am here. –  Jun 28 '18 at 14:11
  • Yeah, sure, it uses jQuery `each` loop instead of a `for` loop and a different googlemaps function, which are pretty much equivalent in this case. I can't see any reason why you couldn't apply the code in your particular case. – Teemu Jun 28 '18 at 14:14
  • 1
    Have you read this https://developers.google.com/maps/premium/previous-licenses/articles/usage-limits?hl=es ? you have to wait 2 seconds or try Teemu suggestion – Emeeus Jun 28 '18 at 14:16

0 Answers0