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