title: Google Maps API v3 - Add marker after initialize
body: <p>My end-goal: Load only map markers within current map viewport and if map is moved, reload map markers within new viewport. </p>
  
  <p>As far as I know, to do this I need the map corner coordinates which I can only load once the map is idle, that way I can pass these coords to my PHP file to query my database and output the XML for the map markers within the corners (I'm trying to reduce the stress on my DB by restricting the query to only the relevant map area). I'm having trouble adding a dummy marker post-initialize (see code below). It's simply not loading the marker, everything else works fine.</p>
  
  <pre><code>&lt;script src="https://maps.googleapis.com/maps/api/js?v=3.exp"&gt;&lt;/script&gt;
  
  &lt;script&gt;
  
  function initialize() {
      var map = new google.maps.Map(document.getElementById("googleMap"), {
       zoom: 12,
       center: new google.maps.LatLng(40.779502, -73.967857)
      });
  
      google.maps.event.addListener(map, 'idle', function() {
           /*bounds =  map.getBounds();
           ne = bounds.getNorthEast();
           sw = bounds.getSouthWest();
           window.top.showBounds();*/
           TestMarker();
  
      });
  }
  
  function addMarker(location) {
      marker = new google.maps.Marker({
          position: location,
          map: map
      });
  }
  
  // Testing the addMarker function
  function TestMarker() {
         CentralPark = new google.maps.LatLng(40.779502, -73.967857);
         addMarker(CentralPark);
  }
  
  google.maps.event.addDomListener(window, 'load', initialize);
  
  &lt;/script&gt;
  </code></pre>