未捕获RangeError:当我尝试设置边界时,超出Google地图的最大调用堆栈大小
我创build了一个工作的谷歌地图,我现在试图自动缩小所以所有的点适合。
当我补充说:
var bounds = new google.maps.LatLngBounds();
和
bounds.extend(point); map.fitBounds(bounds);
然后我得到这个错误:
Uncaught RangeError: Maximum call stack size exceeded J.get (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf J.set (anonymous function) Ey.(anonymous function).zoomRange_changed Zf
我所有的创build地图的代码是:
function load() { var map = new google.maps.Map(document.getElementById("map"), { center: new google.maps.LatLng(47.6145, -122.3418), zoom: 13, mapTypeId: 'roadmap' }); var infoWindow = new google.maps.InfoWindow; // Change this depending on the name of your PHP file downloadUrl("getMapMarkers.php", function(data) { var bounds = new google.maps.LatLngBounds(); var xml = data.responseXML; var markers = xml.documentElement.getElementsByTagName("marker"); for (var i = 0; i < markers.length; i++) { var name = markers[i].getAttribute("name"); var type = markers[i].getAttribute("type"); var point = new google.maps.LatLng( parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng"))); var html = "<b>" + name + "</b> <br/>" ; var icon = customIcons[type] || {}; var marker = new google.maps.Marker({ map: map, position: point, icon: icon.icon, shadow: icon.shadow }); bindInfoWindow(marker, map, infoWindow, html); bounds.extend(point); map.fitBounds(bounds); } }); }
我刚刚遇到了同样的exception,结果是传入“new google.maps.LatLng”的经度未定义。
可能的情况
-
map.fitBounds(bounds);
没有收到纬度/经度或两者。 - 收到的纬度/经度值格式不正确(NaN)。
我使用谷歌地图插件: http : //code.google.com/p/jquery-ui-map/我发现自己与同样的问题,作为奥利点,我有我的JSON格式不好。 这是我的json
mapObj= [ { "latitude": 57.797333, "longitude": 12.050211, "title": "Angered", "content": "Representing :)" }, { "latitude": 57.696995, "longitude": "11.9865", "title": "Gothenburg", "content": "Swedens second largest city" } ]
由于经度写成一个string,我得到了这个错误。
求助:把所有的坐标都作为数字。
要添加地图(假设本地JSON,如果没有参考引用链接):
$('#map_canvas').gmap().bind('init', function() { $.each( mapObj, function(i, marker) { $('#map_canvas').gmap('addMarker', { 'position': new google.maps.LatLng(marker.latitude, marker.longitude), 'bounds': true }).click(function() { $('#map_canvas').gmap('openInfoWindow', { 'content': marker.content }, this); }); }); });
将地图中心设置为不支持lat / long也会产生这个错误。
- 如何将地址转换为Google Maps链接(NOT MAP)
- Google Maps API v3 – getBounds未定义
- 在Google地图上点击添加标记
- 检测距离给定位置最近的公交站点
- 如何从Google Maps JavaScript地理编码器callback中返回variables?
- Android:我如何将地图视图的缩放级别设置为我当前位置周围1公里的半径?
- Android中的INSTALL_FAILED_MISSING_SHARED_LIBRARY错误
- 我如何从我的原生应用程序中启动Google Maps iPhone应用程序?
- 我怎样才能parsing出点,并在Android的谷歌地图绘制路线?