如何延迟这样的功能?

时间:2018-06-28 13:58:23

标签: javascript google-maps

因此,我有一个函数,该函数从.csv文件中获取多个地址,并使用Google地理编码api将它们转换为latlng。然后使用google's map api将其映射为标记。

我在运行函数时遇到OVER_QUERY_LIMIT error的问题,想知道是否有任何方法可以减慢像这样构建的函数的速度?

我的功能:

 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);
     }
   });
   }
 }

0 个答案:

没有答案