【问题标题】:Over query limit and maximum call stack size超过查询限制和最大调用堆栈大小
【发布时间】:2013-09-01 21:49:47
【问题描述】:

在这里,我使用谷歌地图、谷歌地点、路线库库创建了一个代码,以显示两个位置之间的方向,并用谷歌地点显示靠近方向(10、20、30 英里)的对象。

这里是演示和代码:http://jsbin.com/EVEWOta/55,但在尝试了从马德里到莫斯科的“10 英里”距离后,我得到了这个错误:

    ...
    ...
    ...


   OVER_QUERY_LIMIT 55:121
    199
    OVER_QUERY_LIMIT 55:121
    OK 55:121
    1268
    OVER_QUERY_LIMIT 55:121
    3
    OVER_QUERY_LIMIT
    Uncaught RangeError: Maximum call stack size exceeded 

这段代码:

service.nearbySearch(request, function (results, status) {
    console.log(status);
    if (status == 'OVER_QUERY_LIMIT') {
        setTimeout(findPlaces(boxes,searchIndex),10000);
    }else{
        document.getElementById('side_bar').innerHTML += "bounds["+searchIndex+"] returns "+results.length+" results<br>";

        for (var i = 0, result; result = results[i]; i++) {
            var marker = createMarker(result);
        }
        if (++searchIndex < boxes.length) 
            setTimeout(findPlaces(boxes,searchIndex),10000);
    }
  });

此代码停止在框 [14] 中搜索。为什么?

我在调用下一个框之前用 10s 输入代码 setTimeot?

这里真正的问题是什么?

【问题讨论】:

  • 什么是:Uncaught RangeError: Maximum call stack size exceeded ,以及为什么我在 pt setTimeot 10s 时得到 Over query limit ...我认为脚本工作得更快...

标签: javascript limit settimeout google-places-api callstack


【解决方案1】:

您必须将findPlaces 的调用包装到一个函数中,否则该函数将立即被调用,而不是期望的延迟:

setTimeout(function(){findPlaces(boxes,searchIndex);},10000);

【讨论】:

    猜你喜欢
    • 2020-01-05
    • 2020-08-10
    • 1970-01-01
    • 1970-01-01
    • 2017-02-04
    • 2014-08-19
    • 1970-01-01
    • 2015-10-24
    • 2015-12-29
    相关资源
    最近更新 更多