I created a working google map that I am now trying to have auto zoom out so all the points fit.
When I added:
var bounds = new google.maps.LatLngBounds();
and
bounds.extend(point); map.fitBounds(bounds);
I then get this error:
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
All my code for creating the map is:
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); } }); }
I've just run into the same exception, it turned out to be that the longitude passed into "new google.maps.LatLng" was undefined.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With