Javascript 是什么导致“未捕获的范围错误:超出最大调用堆栈大小”错误?(Chrome,在其他浏览器中显示其他消息)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12426208/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 07:56:52  来源:igfitidea点击:

What makes an "Uncaught RangeError: Maximum call stack size exceeded" error? (Chrome, in other browsers other message)

javascriptjqueryloopsgoogle-maps-api-3history.js

提问by Roman M. Koss

Culdn`t find what makes that error, and how to find a solution...

无法找到导致该错误的原因,以及如何找到解决方案...

Working under project:

项目工作

http://atlas.sitegist.net/business/atlas/?l=en&h=6dff16b6f593384662cb24d66142047a

http://atlas.sitegist.net/business/atlas/?l=en&h=6dff16b6f593384662cb24d66142047a

In project i show different data with integer values, and all that also shown on a map. When i added another visualisation of new data set, error occurs.

在项目中,我用整数值显示不同的数据,所有数据也显示在地图上。当我添加新数据集的另一个可视化时,发生错误。

Testing information:

测试信息:

Mostly i must do some events in UI, and of course doing some mixing of listed under:

大多数情况下,我必须在 UI 中做一些事件,当然还要做一些下面列出的混合:

  • must click "Projects" button, and then check/uncheck checkboxes in toolbar section of my project
  • must click events on left sidebar panel (No need to expand collapse, for given data set selection of objects is made by choosing on of the parents)
  • 必须单击“项目”按钮,然后在我的项目的工具栏部分选中/取消选中复选框
  • 必须单击左侧边栏面板上的事件(无需展开折叠,对于给定的数据集,对象的选择是通过选择父项进行的)

Sometimes error ocuurs in 5 min. Sometimes in first shot, but ostly in 3-4 UI request.

有时错误会在 5 分钟内发生。有时在第一次拍摄中,但主要是在 3-4 个 UI 请求中。

the link above reproduce an error from start, or by 2-3 event triggers.

上面的链接从头开始或通过 2-3 个事件触发器重现错误。

Errors: Copy paste from console

错误:从控制台复制粘贴

And such error i have in Chrome console:

我在 Chrome 控制台中有这样的错误:

Uncaught RangeError: Maximum call stack size exceeded
H.get
(anonymous function)
Mu.(anonymous function).zoomRange_changed
yf
H.set
(anonymous function)
Mu.(anonymous function).zoomRange_changed
yf
H.set
(anonymous function)
Mu.(anonymous function).zoomRange_changed
yf
...
H.set
(anonymous function)
Mu.(anonymous function).zoomRange_changed
yf

And onother one:

还有一个:

<error>
(anonymous function)
$
nm
Du
H.bf
H.mapType_changed
yf
H.set
H.aa
Tg.(anonymous function).J
(anonymous function)
Q.trigger
H.aa
Tg.(anonymous function).J
(anonymous function)
Q.trigger
H.aa
Tg.(anonymous function).J
(anonymous function)
Q.trigger
H.aa
...
H.aa
Tg.(anonymous function).J
(anonymous function)
Q.trigger

Solution under solution didn nott helped me, couse of lack of information about I.set and also I don`t use "Gmaps4rails":

解决方案下的解决方案对我没有帮助,因为缺乏有关 I.set 的信息,而且我不使用“Gmaps4rails”:

Gmaps4rails Maximum call stack size exceeded?

Gmaps4rails 超出最大调用堆栈大小?

采纳答案by Roman M. Koss

Solved!!!

解决了!!!

I found a problem in my boundsvariable.

我在我的bounds变量中发现了一个问题。

When i receiving JSON from server, while parsing it, the code makes bound from each location on a map.

当我从服务器接收 JSON 时,在解析它时,代码从地图上的每个位置进行绑定。

// renew map bounds each time when new query comes
bounds = new google.maps.LatLngBounds ();
...
for (var key in data.locations ) {
    ...
    // For fitting in Bounds, we push the positions of each location
    atlas.Map.vars.bounds.extend ( new google.maps.LatLng(
        data.locations [key].lat,
        data.locations [key].lng
    ) );    
    ...
}
...
GoogleMap.fitBounds (bounds);

And somehow for the new data type it`s making browser stack to overflow.

不知何故,对于新的数据类型,它使浏览器堆栈溢出。

(what is very strange, cause it works normal for a even a lot bigier results! (600< elements on a map)).

(很奇怪,因为它对于更大的结果正常工作!(地图上的 600< 元素))。

Made a brute code for fast result:

为快速结果制作了一个蛮力代码:

bounds = new google.maps.LatLngBounds ();
if( KMLLayer.poly.docs[0].bounds != undefined ) {
    bounds.extend( KMLLayer.poly.docs[0].bounds.getNorthEast() );
    bounds.extend( KMLLayer.poly.docs[0].bounds.getSouthWest() );
}
if( KMLLayer.marks.docs[0].bounds != undefined ) {
    bounds.extend( KMLLayer.marks.docs[0].bounds.getNorthEast() );
    bounds.extend( KMLLayer.marks.docs[0].bounds.getSouthWest() );
}
GoogleMap.fitBounds (bounds);

I have two KML layers, so i retrieved bounds, if there occurs some, from GeoXML3 layers.

我有两个 KML 层,所以我从 GeoXML3 层中检索了边界(如果有的话)。

Damn, i spend for it 6 hours and 38 minutes!!!

该死,我花了 6 小时 38 分钟!!!

Maybe i was wrong with this line, what clears global variable badly:

也许我错了这一行,是什么清除了全局变量:

bounds = new google.maps.LatLngBounds ();

original name of variables are litle longer :) bounds === atlas.Map.vars.bounds;

变量的原始名称有点长:) bounds === atlas.Map.vars.bounds;

回答by Bas G

I received the same error. However in my case the issue had to do with the lat and long data. It was one dot short which resulted in this issue.

我收到了同样的错误。但是,在我的情况下,问题与经纬度数据有关。导致此问题的原因是少了一个点。

Related: https://groups.google.com/forum/?fromgroups=#!topic/google-maps-js-api-v3/1SCjxGntruU

相关:https: //groups.google.com/forum/?fromgroups=#!topic/google-maps-js-api-v3/1SCjxGntruU

回答by kaiser

This error normally occurs (in Google Chrome) when you forgot to set allminimumoptions for your map. Those are the following:

当您忘记为地图设置所有最小选项时,通常会发生此错误(在 Google Chrome 中)。这些是以下内容:

var map = new google.maps.Map(
    document.getElementById( 'some-id' ),
    {
        center :    new google.maps.LatLng( 43, 16 ),
        zoom :      10,
        mapTypeId : google.maps.MapTypeId.ROADMAP
    }
);

回答by David Lamm

Does your polygon path contain any empty LatLng?

您的多边形路径是否包含任何空的 LatLng?

I received the same error when this occured - Stupid mistake but might help someone in a similar situation.

发生这种情况时,我收到了同样的错误 - 愚蠢的错误,但可能会帮助处于类似情况的人。