Uncaught RangeError: Maximum call stack size exceeded Google maps when I try to set 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.
Possible scenarios
- Either
map.fitBounds(bounds);
is not receiving latitude/longitude or both. - The received values of latitude/longitude are not in correct format(NaN).
I used google map plugin: http://code.google.com/p/jquery-ui-map/ I found myself with the same problem, and as Ollie point, I had my json bad formatted. This was my 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"
}
]
Because of that longitude written as a string, I was getting that error.
SOLVED: Having all coordinates as numbers.!
To add the map (assuming local json, if not refer to reference link):
$('#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);
});
});
});
Setting map center to a not supported lat/long also produces this error.