title: Google Map API v3 - map.fitBounds(bounds) causes Maximum call stack size exceeded error
body: <p>I am using Google Maps API V3, plotting markers from an array.  I am trying to center and zoom to the markers.  The problem I am having is that as soon as I try to use this line:</p>
  
  <p><code>map.fitBounds(bounds);</code> </p>
  
  <p>I get this error: </p>
  
  <p><code>Uncaught RangeError: Maximum call stack size exceeded</code></p>
  
  <p>When I comment-out the fitBounds line, everything works fine and the markers are plotted, although the map is not centered and zoomed correctly.  Is there something wrong with the way that I have structured this code that might be causing the error?</p>
  
  <pre><code>function setMarkers(map, data) {
    var bounds = new google.maps.LatLngBounds();
    for (var i = 0; i &lt; data.length; i++) {
    var salecomp = data[i];
    var myLatLng = new google.maps.LatLng(data[i].latitude, data[i].longitude);               
    var marker = new google.maps.Marker({
      position: myLatLng, 
      map: map, 
      title:data.address });          
    bounds.extend(myLatLng);
    }
    map.fitBounds(bounds); // THIS IS THE LINE CAUSING THE ERROR
  }           
  </code></pre>
  
  <p>When I alert the value of <code>bounds</code>, it appears that one of the latitude or longitude values may be null.  Could this be the reason for the error?</p>
  
  <p><img src="https://i.stack.imgur.com/beGPK.png" alt="value of bounds"></p>