title: Mapping multiple locations with Google Maps JavaScript API v3 and Geocoding API
body: <p>I'm using Google Maps JavaScript API v3 to generate a map with multiple locations/markers. I only have the address for these locations, not the coordinates, so I'm using the Geocoding API to get the coordinates.</p>
  
  <p>I finally got Google's geocoding to work, so the location markers are showing up where they are supposed to be. However, the <em>same content</em> is showing up in every InfoWindow. I seem to be unable to pass the location arrays into the geocode function. (Incidentally, I also tried creating a variable for the geocode results  and moving the infoWindow function <em>outside</em> of the geocode function, but I couldn't make that work either.)</p>
  
  <p>I've tried this a hundred different ways already. I hoping someone else will see what I haven't been able to see.</p>
  
  <pre><code>    var locations = [
          ['Location 1 Name', 'Location 1 Address', 'Location 1 URL'],
          ['Location 2 Name', 'Location 2 Address', 'Location 2 URL'],
          ['Location 3 Name', 'Location 3 Address', 'Location 3 URL']
      ];
  
      geocoder = new google.maps.Geocoder();
  
      for (i = 0; i &lt; locations.length; i++) {
  
          title = locations[i][0];
          address = locations[i][1];
          url = locations[i][2];
  
          geocoder.geocode({ 'address' : locations[i][1] }, function(results, status) {
            marker = new google.maps.Marker({
                icon: 'marker_blue.png',
                map: map,
                position: results[0].geometry.location,
                title: title,
                animation: google.maps.Animation.DROP,
                address: address,
                url: url
            })
            infoWindow(marker, map, title, address, url);
          })
  
      }
  
      function infoWindow(marker, map, title, address, url) {
          google.maps.event.addListener(marker, 'click', function() {
              var html = "&lt;div&gt;&lt;h3&gt;" + title + "&lt;/h3&gt;&lt;p&gt;" + address + "&lt;br&gt;&lt;/div&gt;&lt;a href='" + url + "'&gt;View location&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;";
              iw = new google.maps.InfoWindow({ content : html, maxWidth : 350});
              iw.open(map,marker);
          });
      }
  </code></pre>