0

I am trying to print out a list of places around certain addresses (~200 addresses). However, when I run this code I only get place results for 6 addresses and then in the console I get the message 'Uncaught RangeError: Maximum call stack size exceeded'. I know that my lat and long values are formatted correctly, and set a TimeOut in case I was going over my query limit, does anyone have any ideas on how I can get responses for all 200 addresses? Thanks

function run(){
    for (var i=100; i<latss.length;i ++){
        var lat = data[i].Lats;
        var long = data[i].Longs;
        var latlng = new google.maps.LatLng(lat, long);
        //var address= data[i].Address
        GetJsonResults(latlng, address)
        }
}
run();

function GetJsonResults(latlng){
    var service = new google.maps.places.PlacesService(map);

        service.nearbySearch({
            location: latlng,
            radius: 50,
            type: ['type']
        }, 


    function callback(results, status) {
        var GoodTypes= [];
        if (status === google.maps.places.PlacesServiceStatus.OK) {
            for (var i = 0; i < results.length; i++) {
                var type =results[i].types;
                var name= results[i].name
                console.log(results[i])

            }
        }
      else {setTimeout(run(), 200)}
        })



}
Matt Polers
  • 43
  • 1
  • 4
  • You probably don't want to call `run` every 200ms when it is failing... – geocodezip Aug 09 '16 at 16:42
  • I've changed it to as high as 5s per call – Matt Polers Aug 09 '16 at 16:53
  • the `run` function starts from the beginning each time... (well, half way through) you really only want to retry the ones that failed for to OVER_QUERY_LIMIT. – geocodezip Aug 09 '16 at 16:59
  • Is that a problem? I know its running fine for the first 6 or so. – Matt Polers Aug 09 '16 at 17:09
  • 1
    possible duplicate of [OVER_QUERY_LIMIT in Google Maps API v3: How do I pause/delay in Javascript to slow it down?](http://stackoverflow.com/questions/11792916/over-query-limit-in-google-maps-api-v3-how-do-i-pause-delay-in-javascript-to-sl) – geocodezip Aug 09 '16 at 17:48
  • I'm not getting an OVER_QUERY_LIMIT status however, and I am pausing for long enough that I shouldn't be going over the Query Limit – Matt Polers Aug 09 '16 at 18:18

0 Answers0