title: Looping through Markers with Google Maps API v3 Problem
body: <p>I'm not sure why this isn't working. I don't have any errors, but what happens is, no matter what marker I click on, it always clicks the last marker. Im not sure why though because the_marker is set up the same way. How can I fix this?:</p>
  
  <p>(Updated with new jQuery + XML)</p>
  
  <pre><code>$(function(){
      var latlng = new google.maps.LatLng(45.522015,-122.683811);
      var settings = {
          zoom: 15,
          center: latlng,
          disableDefaultUI:true,
          mapTypeId: google.maps.MapTypeId.SATELLITE
      };
      var map = new google.maps.Map(document.getElementById("map_canvas"), settings);
  
      $.get('mapdata.xml',{},function(xml){
          $('location',xml).each(function(i){
              the_marker = new google.maps.Marker({
                  title:$(this).find('name').text(),
                  map:map,
                  clickable:true,
                  position:new google.maps.LatLng(
                      parseFloat($(this).find('lat').text()),
                      parseFloat($(this).find('lng').text())
                  )
              });
              infowindow = new google.maps.InfoWindow({
                  content: $(this).find('description').text()
              });
              new google.maps.event.addListener(the_marker, 'click', function() {
                  infowindow.open(map,the_marker);
              });
          });
      });
  });
  </code></pre>