因此,我有一个函数,该函数从.csv
文件中获取多个地址,并使用Google地理编码api将它们转换为lat
和lng
。然后使用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);
}
});
}
}