title: Calling map.fitBounds() Multiple Times in Google Maps API v3.0
body: <p>I've just begun using the Google Maps API (v3.0) and have had a good deal of success so far. I am loading a set of objects with Latitude &amp; Longitude values from a database, passing them into my script, and looping over them in the script in order to add them to the map.</p>
  
  <p>I am using the "<code>bounds.extend()</code> / <code>map.fitBounds()</code>" method of setting the map's zoom &amp; bounds (see code below), which works as expected the first time around; however, if I clear out the existing markers, fetch another set of objects, and do the same thing <em>on the same map instance</em>, it sets the bounds incorrectly, usually resulting in a minimum zoom (an astronaut's view). </p>
  
  <p>My suspicion is that my map object has some memory of the previous set of bounds that I've given it and that I need to find a way to clear these bounds before assigning my new ones, but I really can't be too sure.</p>
  
  <p>Any help is greatly appreciated!</p>
  
  <pre><code>var locationList = [];
  for (var i = 0; i &lt; mapPoints.length; i++) { // mapPoints is a collection of DTOs
      var mapPoint = mapPoints[i];
      var location = new google.maps.LatLng(mapPoint.Latitude, mapPoint.Longitude);
      locationList.push(location);
  
      var marker = new google.maps.Marker({
          map: map,
          icon: '/Content/images/map/' + mapPoint.Status.Icon,
          shadow:  '/Content/images/map/shadow.png',
          position: location
      });
      markers.push(marker); // markers is an Array that is managed outside this loop
  }
  
  var bounds = new google.maps.LatLngBounds();
  for (var j = 0; j &lt; locationList.length; j++) 
      bounds.extend(locationList[j]);
  map.fitBounds(bounds);
  </code></pre>