title: Loading XML via jQuery for Google Maps API V3
body: <p><strong>UPDATE:</strong>
  Fatigue onset user error, not the code itself, turned out to be the problem. I simply called the <code>initialize()</code> function twice by mistake. I'll leave this post up as the code snippet may be of some use to others hoping to consume XML data for a Google Map via jQuery.</p>
  
  <p>I am loading map marker coordinates and infoWindow content from an XML file via jQuery for Google Maps (API V3). Everything appears to be working fine<strike>, except for the fact that every marker is added twice</strike>.</p>
  
  <p>Here is my JS:</p>
  
  <pre><code>google.load("maps", "3",  {other_params:"sensor=false"});
  google.load("jquery", "1.6.2");
  
  var infowindow;
  var map;
  
  function initialize() {
  
  // Specify center of the map
  var latLng = new google.maps.LatLng(51.781,-107.402);
  
  // Customize map appearance
  var mapOptions = {
      center: latLng,
      mapTypeControl: false,
      mapTypeId: 'roadmap',
      navigationControl: true,
      navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL, position: google.maps.ControlPosition.TOP_RIGHT},
      scaleControl: false,
      streetViewControl: false,
      zoom: 3
  } // end mapOptions();
  
  // Load the Google map into the #mapCanvas div
  map = new google.maps.Map(document.getElementById("mapCanvas"), mapOptions);
  
  jQuery.get("iphorm/test.xml", function(data) {
    jQuery(data).find("marker").each(function() {
      var eachMarker = jQuery(this);
      var markerCoords = new google.maps.LatLng(
          parseFloat(eachMarker.find("Latitude").text()),
          parseFloat(eachMarker.find("Longitude").text())
      );
      var name = eachMarker.find("Name").text();
      var content = eachMarker.find("Content").text();
      var html = "&lt;div class='info-blob'&gt;" + name + "&lt;br /&gt;" + content + "&lt;/div&gt;";
  
      var marker = addMarker(html, markerCoords);
  
      });
    });
  } // end initialize();
  
  // Create a marker for each XML entry
  function addMarker(html, markerCoords) {
  
  // Place the new marker
  var marker = new google.maps.Marker({
      animation: google.maps.Animation.DROP,
      map: map,
      position: markerCoords
  }); // end place the new marker
  
  // Add event listener. On marker click, close all open infoWindows open current infoWindow.
  google.maps.event.addListener(marker, "click", function() {
      if (infowindow) infowindow.close();
      infowindow = new google.maps.InfoWindow({content: html});
      infowindow.open(map, marker);
  }); // end add event listener
  
  // Display marker
  return marker;
  
  } // end addMarker();
  
  // On page lod, initialize the map
  google.setOnLoadCallback(initialize);
  </code></pre>
  
  <p>My XML file looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;markers&gt;
          &lt;marker&gt;
              &lt;Name&gt;Jane Smith&lt;/Name&gt;
              &lt;Content&gt;A bit of content goes here.&lt;/Content&gt;
              &lt;Latitude&gt;53.69629&lt;/Latitude&gt;
              &lt;Longitude&gt;-123.925437&lt;/Longitude&gt;
          &lt;/marker&gt;
          &lt;marker&gt;
              &lt;Name&gt;Joe Smith&lt;/Name&gt;
              &lt;Content&gt;A bit of content goes here.&lt;/Content&gt;
              &lt;Latitude&gt;55.627598&lt;/Latitude&gt;
              &lt;Longitude&gt;-115.136375&lt;/Longitude&gt;
          &lt;/marker&gt;
  &lt;/markers&gt;
  </code></pre>
  
  <p>Obviously, each <code>&lt;marker&gt;</code> element from the XML should only be grabbed once for the map. <strike>Any ideas on how to fix this error?</strike> <strong>Edit:</strong> Code works as intended.</p>