title: google.maps.event.trigger not triggering after map load
body: <p>I have a google map that updates all the markers on it upon <code>dragend</code> and <code>zoom_changed</code> events. It's all working except the initial load of the map. After the map has loaded it is empty. At the end of <code>initialize()</code> I call <code>google.maps.event.trigger(map, 'dragend')</code> to try to call the <code>dealWithNewWindow</code> function so the map fills with markers, but nothing happens?</p>
  
  <pre><code>initialize = function() {
    mapOptions = {
      center: { lat: 51, lng: 0 },
      zoom: 9
    };
    map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
    map.setCenter(new google.maps.LatLng(51,0));
    google.maps.event.addListener(map, 'zoom_changed', dealWithNewWindow);
    google.maps.event.addListener(map, 'dragend', dealWithNewWindow);
    function dealWithNewWindow(event) {
      killAllMarkers();
      var bounds = map.getBounds();
      var nelat = bounds.getNorthEast().lat();
      var swlat = bounds.getSouthWest().lat();
      var nelng = bounds.getNorthEast().lng();
      var swlng = bounds.getSouthWest().lng();
      var mapBounds = {NElatitude:nelat, SWlatitude:swlat, NElongitude:nelng, SWlongitude:swlng};
      $.ajax({
        type     : 'POST',
        url      : '/maprequest',
        dataType : 'script',
        data     :  {  NElatitude:nelat, SWlatitude:swlat, NElongitude:nelng, SWlongitude:swlng }
      });
    };
    google.maps.event.trigger(map, 'dragend');
  };
  
  google.maps.event.addDomListener(window, 'load', initialize);
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>I've homed in a bit on the problem. After a page refresh the javascript grinds to a halt during this line in dealWithNewWindow: <code>var nelat = bounds.getNorthEast().lat();</code>. For some reason this code runs fine when the map bounds are changed afterwards, but it fails the first time the map is loaded.</p>