title: Google Maps API, error with InfoWindow domready event handler
body: <p>I'm setting up a form within an info info window for crowd-sourcing location data.  I've got everything up and running, but I'm trying to copy the lat and lng values into the form elements when the info window pops open.</p>
  
  <p>I've been successful with other event listener on the map div, but when I use the <code>domready</code>event handler for the info window I get an error: </p>
  
  <blockquote>
    <p>"Uncaught TypeError: Cannot read property '__e3_' of undefined."  </p>
  </blockquote>
  
  <p>The issue seems to be within the <code>domready</code> event listener.</p>
  
  <pre><code>// Global Variables
  var map, markerWindow, newMarker;
  
  function updateMarkerPosition(latLng) {
      alert(latLng);
      var lat = latLng.lat().toString();
      var lng = latLng.lng().toString();
      google.maps.event.addListener(markerWindow, "domready", function() {
          alert(latLng); // debug alert
          document.getElementById('lat').value = lat.slice(0,6);
          document.getElementById('lng').value = lng.slice(0,7);
      });
  }
  function placeMarker() {
  // Setup html form markup for marker pop-up infowindow
      var html = '&lt;div id="htmlform"&gt;' +
          '&lt;form action="process.php" method="post" ' +
          'id="mapForm"&gt; &lt;fieldset&gt; &lt;label for="contact"&gt;' +
          'Email:&lt;/label&gt;&lt;input type="text" name="contact"/&gt;' +
          '&lt;br/&gt; &lt;label for="date"&gt;Date:&lt;/label&gt;&lt;input ' +
          'type="text" name="date"/&gt;&lt;br/&gt; &lt;label for="desc"&gt;' +
          'Description of Sighting:&lt;/label&gt;&lt;input type="text" ' +
          'name="desc"/&gt;&lt;br/&gt; &lt;label for="lat"&gt;Latitude:&lt;/label&gt;' +
          '&lt;input type="text" name="lat" id="lat" class="location"/&gt;&lt;br/&gt;' +
          '&lt;label for="lng"&gt;Longitude:&lt;/label&gt;&lt;input type="text"' +
          'name="lng" id="lng" class="location"/&gt;&lt;br/&gt;&lt;input type="submit"' +
          'value="Post Sighting!" onclick="saveData()"/&gt; &lt;/fieldset&gt;&lt;/form&gt;' +
          '&lt;/div&gt;';
      var newMarker = new google.maps.Marker( {
          draggable: true,
          map: map,
          animation: google.maps.Animation.DROP,
          title: "I'm draggable!",
      });
      var markerWindow = new google.maps.InfoWindow({
          content: html,
      }); 
      google.maps.event.addListener(map, "click", function(e) {
          newMarker.setPosition(e.latLng);
          markerWindow.open(map, newMarker);
          map.setCenter(e.latLng);
          updateMarkerPosition(newMarker.getPosition());
      });             
      google.maps.event.addListener(newMarker, 'dragstart', function() {
          markerWindow.close();
      });
      google.maps.event.addListener(newMarker, 'dragend', function(e) {
          newMarker.setPosition(e.latLng);
          markerWindow.open(map, newMarker);
          updateMarkerPosition(newMarker.getPosition());
      });
  }
  // Run when DOM window loads
  function initialize() {
      map = new google.maps.Map(document.getElementById('map_canvas'),{
          zoom: 8,
          center: new google.maps.LatLng(38.487, -75.641),
          mapTypeId: google.maps.MapTypeId.ROADMAP
      });
      placeMarker();
  }
  google.maps.event.addDomListener(window, 'load', initialize);
  </code></pre>