0

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);
Tsuna
  • 2,098
  • 6
  • 24
  • 46
  • `I have read that post already and it is the closes post I can find` - yeah, it's a pretty poor answer!! We expect questions to include code in the question, but answers seem to not require useful code! You've have to look at the source code in the link in that question! and it's 5 years old to boot! – Jaromanda X Aug 19 '17 at 02:23
  • Not sure if this will help https://pastebin.com/g51VCdHJ - it uses promises, because I wrote it for something I needed a couple of years ago. Note:I tried posting it on jsfiddle, but jsfiddle is not working for me at the moment!! – Jaromanda X Aug 19 '17 at 02:31
  • ugh, that code was so wrong ... - https://pastebin.com/X37fzxwr is better – Jaromanda X Aug 19 '17 at 03:15
  • not my day, there's still a typo in that one - `const gecodePromise` should be `const geocodePromise` – Jaromanda X Aug 19 '17 at 03:22

0 Answers0