为啥谷歌地图在几次回帖后冻结页面

Posted

技术标签:

【中文标题】为啥谷歌地图在几次回帖后冻结页面【英文标题】:Why does google map freeze page after a few post backs为什么谷歌地图在几次回帖后冻结页面 【发布时间】:2011-08-30 20:36:11 【问题描述】:

我遇到了最奇怪的问题。我无法弄清楚为什么我正在构建的网站上的谷歌地图在大约 5 或 6 次回发后会慢慢冻结页面。我目前在更新面板中使用日历,后退和下一个按钮会导致谷歌地图做奇怪的事情。我删除了更新面板,它仍然做同样的事情。单击大约 3 次后,标记图标开始缓慢模糊并最终变黑。它让我发疯。任何想法都会非常有帮助。谢谢。有问题的页面的链接是http://adkrenter.com/properties/106-plum-poppy-north,它在 ie 和 firefox 中都有。

【问题讨论】:

我无法重现错误,你能一步一步告诉我们吗? 如果你点击下一个按钮,然后点击上一个按钮,然后下一个按钮,它在大约 4 次后开始变得时髦。观察标记图标,它们会慢慢像素化然后变黑,然后页面就开始冻结。我有下一套要进行 5 年,但到了第 5 年,它完成了。 【参考方案1】:

您的根本问题是,每次点击PrevNext 时,您在同一位置的地图上添加的标记数量是之前的 3 倍。

我无法告诉你为什么会发生这种情况(或如何解决它)而没有看到更多代码(浏览页面源代码很痛苦,所以如果你可以发布一些相关的代码'正在点击,这可能会有所帮助)

更新

我查看了大约 7 到 10 次点击后的响应,这是一个巨大的(相对而言,初始响应只有几十 KB)168 KB 其中 143 KB 是 javascript 代码,用于将相同的标记添加到两者页面上的地图 - 每个 162 次!难怪页面冻结。

这是响应的一部分:

var GoogleMap1 = new Artem.Web.GoogleMap("Address":"106 Plum Poppy North, Malta , NY, 12020","BaseCountryCode":null,"ClientID":"ctl05_GoogleMap1","ClientMapID":"GoogleMap1","DefaultAddress":null,"DefaultMapView":0,"Directions":[],"EnableContinuousZoom":false,"EnableDoubleClickZoom":false,"EnableDragging":true,"EnableGoogleBar":false,"EnableInfoWindow":true,"EnableMarkerManager":false,"EnableReverseGeocoding":false,"EnableScrollWheelZoom":false,"EnterpriseKey":null,"Height":"130px","IsStreetView":false,"IsStatic":false,"Key":"ABQIAAAATFt6mjpmHxeLQ689NDV5WhTHwM4h-1LWnzPqjMrWYJQMyFF86hTACw-YJNmRQV0Dk4jcB3zQHvdUsw","Latitude":42.968839,"Longitude":-73.777681,"MapEvents":,"MarkerEvents":,"MarkerManagerOptions":"borderPadding":null,"maxZoom":null,"trackMarkers":null,"PolygonEvents":,"PolylineEvents":,"ShowMapTypeControl":false,"ShowScaleControl":false,"ShowTraffic":false,"StreetViewMode":0,"StreetViewPanoID":null,"Width":"190px","Zoom":14,"ZoomPanType":0);
GoogleMap1.addMarker("Address":"106 Plum Poppy North, Malta , NY, 12020","AutoPan":true,"Bouncy":false,"Clickable":true,"Draggable":false,"DragCrossMove":false,"IconAnchor":"X":0,"Y":0,"IconSize":"Height":0,"Width":0,"IconUrl":null,"InfoWindowAnchor":"X":0,"Y":0,"Latitude":42.968839,"Longitude":-73.777681,"MaxZoom":null,"MinZoom":null,"OpenInfoBehaviour":0,"ShadowSize":"Height":0,"Width":0,"ShadowUrl":null,"Text":null,"Title":null);
GoogleMap1.addMarker("Address":"106 Plum Poppy North, Malta , NY, 12020","AutoPan":true,"Bouncy":false,"Clickable":true,"Draggable":false,"DragCrossMove":false,"IconAnchor":"X":0,"Y":0,"IconSize":"Height":0,"Width":0,"IconUrl":null,"InfoWindowAnchor":"X":0,"Y":0,"Latitude":42.968839,"Longitude":-73.777681,"MaxZoom":null,"MinZoom":null,"OpenInfoBehaviour":0,"ShadowSize":"Height":0,"Width":0,"ShadowUrl":null,"Text":null,"Title":null);
GoogleMap1.addMarker("Address":"106 Plum Poppy North, Malta , NY, 12020","AutoPan":true,"Bouncy":false,"Clickable":true,"Draggable":false,"DragCrossMove":false,"IconAnchor":"X":0,"Y":0,"IconSize":"Height":0,"Width":0,"IconUrl":null,"InfoWindowAnchor":"X":0,"Y":0,"Latitude":42.968839,"Longitude":-73.777681,"MaxZoom":null,"MinZoom":null,"OpenInfoBehaviour":0,"ShadowSize":"Height":0,"Width":0,"ShadowUrl":null,"Text":null,"Title":null);
//repeated a few hundred times

GoogleMap2.addMarker("Address":"106 Plum Poppy North, Malta , NY, 12020","AutoPan":true,"Bouncy":false,"Clickable":true,"Draggable":false,"DragCrossMove":false,"IconAnchor":"X":0,"Y":0,"IconSize":"Height":0,"Width":0,"IconUrl":null,"InfoWindowAnchor":"X":0,"Y":0,"Latitude":42.968839,"Longitude":-73.777681,"MaxZoom":null,"MinZoom":null,"OpenInfoBehaviour":0,"ShadowSize":"Height":0,"Width":0,"ShadowUrl":null,"Text":null,"Title":null);
GoogleMap2.addMarker("Address":"106 Plum Poppy North, Malta , NY, 12020","AutoPan":true,"Bouncy":false,"Clickable":true,"Draggable":false,"DragCrossMove":false,"IconAnchor":"X":0,"Y":0,"IconSize":"Height":0,"Width":0,"IconUrl":null,"InfoWindowAnchor":"X":0,"Y":0,"Latitude":42.968839,"Longitude":-73.777681,"MaxZoom":null,"MinZoom":null,"OpenInfoBehaviour":0,"ShadowSize":"Height":0,"Width":0,"ShadowUrl":null,"Text":null,"Title":null);
GoogleMap2.addMarker("Address":"106 Plum Poppy North, Malta , NY, 12020","AutoPan":true,"Bouncy":false,"Clickable":true,"Draggable":false,"DragCrossMove":false,"IconAnchor":"X":0,"Y":0,"IconSize":"Height":0,"Width":0,"IconUrl":null,"InfoWindowAnchor":"X":0,"Y":0,"Latitude":42.968839,"Longitude":-73.777681,"MaxZoom":null,"MinZoom":null,"OpenInfoBehaviour":0,"ShadowSize":"Height":0,"Width":0,"ShadowUrl":null,"Text":null,"Title":null);
GoogleMap2.addMarker("Address":"106 Plum Poppy North, Malta , NY, 12020","AutoPan":true,"Bouncy":false,"Clickable":true,"Draggable":false,"DragCrossMove":false,"IconAnchor":"X":0,"Y":0,"IconSize":"Height":0,"Width":0,"IconUrl":null,"InfoWindowAnchor":"X":0,"Y":0,"Latitude":42.968839,"Longitude":-73.777681,"MaxZoom":null,"MinZoom":null,"OpenInfoBehaviour":0,"ShadowSize":"Height":0,"Width":0,"ShadowUrl":null,"Text":null,"Title":null);
GoogleMap2.addMarker("Address":"106 Plum Poppy North, Malta , NY, 12020","AutoPan":true,"Bouncy":false,"Clickable":true,"Draggable":false,"DragCrossMove":false,"IconAnchor":"X":0,"Y":0,"IconSize":"Height":0,"Width":0,"IconUrl":null,"InfoWindowAnchor":"X":0,"Y":0,"Latitude":42.968839,"Longitude":-73.777681,"MaxZoom":null,"MinZoom":null,"OpenInfoBehaviour":0,"ShadowSize":"Height":0,"Width":0,"ShadowUrl":null,"Text":null,"Title":null);
//repeated a few hundred times

GoogleMap2.load();

我对 .NET 和 C# 不熟悉,因此我无法提供太多帮助,因为我不知道这个“更新面板”是如何工作的。但似乎问题出在服务器上 - 它发送回相同的标记,其计数似乎呈几何增长 - 传入的标记数量是之前标记数量的 3 倍。

【讨论】:

天才。谢谢你。我不知道额外添加的原因。我将不得不追查它。感谢您的开始。

以上是关于为啥谷歌地图在几次回帖后冻结页面的主要内容,如果未能解决你的问题,请参考以下文章

为啥手机上不能用谷歌地图

页面加载后谷歌地图不显示[重复]

如何在几分钟内进入谷歌搜索结果?

有时我在 Android Studio 中遇到谷歌地图问题,但并非总是如此。为啥?如何删除谷歌地图上方的白条?

为啥优步、谷歌地图等印度应用程序中的地图如此不准确?

启用位置后刷新谷歌地图