title: Cannot call method 'getSouthWest' of undefined
body: <p>I'm trying to center the google map on the polyline I've decoded. I get  </p>
  
  <pre><code>Cannot call method 'getSouthWest' of undefined
  </code></pre>
  
  <p>When I call the calcBounds function below. Here's the complete code:</p>
  
  <pre><code>        var map;
  
      $(document).ready(function () {
          var gmCenter = new google.maps.LatLng(33.7489, -84.3881);
          var gmMapType = google.maps.MapTypeId.ROADMAP;
          var mapOptions = { center: gmCenter, zoom: 8, mapTypeId: gmMapType };
          map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
          displayOnMap();
      });
  
      function displayOnMap() {
          var decodedPath = google.maps.geometry.encoding.decodePath('@Model.Polyline');
          var pathOptions = { path: decodedPath, strokeColor: "#FF0000", strokeOpacity: 0.5, strokeWeight: 5 };
          var trackPath = new google.maps.Polyline(pathOptions);
          trackPath.setMap(map);
          map.fitBounds(calcBounds(trackPath));
      }
  
      function calcBounds(trackPath) {
          var b = new google.maps.LatLngBounds();
          var gmPath = trackPath.getPath();
          var pathLength = gmPath.getLength();
          var i = [0, (pathLength / 3).toFixed(0), (pathLength / 3).toFixed(0) * 2];
          b.extend(gmPath.getAt(i[0]));
          b.extend(gmPath.getAt(i[1]));
          b.extend(gmPath.getAt(i[2]));
      }
  </code></pre>
  
  <p>Am I missing an initialization somewhere? </p>
  
  <p>Thanks! </p>