I am trying to generate lots marked locations on google map but I realized there's this error Geocode was not successful for the following reason: OVER_QUERY_LIMIT
which I google around and figured there's limits to query within a timeframe.
I have read a few people's code on how to solve it but I don't know how to implement it into my own code.
Can someone give me a hand or idea to start with?
P.S. I have read that post already and it is the closes post I can find but there are some variables such as delay++
and address--
and next()
I have no idea where they are from. I am reading the posted script and the answer scripts but still somehow confused
This is the code I have currently.
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom : 2,
center: {lat: -34.397, lng: 150.644}
});
var geocoder = new google.maps.Geocoder();
console.log(userAddress);
function generateMap(userAddress){
if (userAddress.length > 0){
for (var i = 0; i < userAddress.length; i++) {
geocoder.geocode({'address': userAddress[i]}, (results, status) => {
if (status === 'OK') {
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);
}
});
}
}
}
generateMap(userAddress);