title: GMaps API V3 - Multiple Markers & InfoWindow
body: <p>I know, it is a recurrent but... I have a big problem with my multiple markers : all of them have the same title and the same infowindow content.</p>
  
  <p>I've searched on many websites, but I didn't find where is the problem in my code. 
  I hope you'll be able to help me (I am sure it is the case !)</p>
  
  <p>This is my code : </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
              var map;
              var geocoder;
              $(document).ready(function() {
                  initializeMap();
              });
  
  
              function initializeMap() {
  
                  var people = [{"userid":"47","lastname":"lastname1","firstname":"firstname1","address":"SomeAddress","phone1":"00000000000","phone2":"","email":"me@me.com"},{"userid":"42","lastname":"lastname2","firstname":"firstname2","address":"SomeAddress2","phone1":"0","phone2":"0","email":"me@me.com"}]; 
  
  
                  var center = new google.maps.LatLng(40.667, -73.833); 
  
                  var myOptions = {
                      zoom: 8,
                      center: center,
                      mapTypeId: google.maps.MapTypeId.ROADMAP
                  };
  
                  map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
                  geocoder = new google.maps.Geocoder();
  
                  for (i = 0; i &lt; people.length; i++) {
                      var p = people[i];
  
  
  
                      geocoder.geocode( { 'address': p["address"]}, function(results, status) {
                          if (status == google.maps.GeocoderStatus.OK) {
                              map.setCenter(results[0].geometry.location);
                              var marker = new google.maps.Marker({
                                  map:map,
                                  draggable:false,
                                  animation: google.maps.Animation.DROP,
                                  title:p["lastname"] + " " + p["firstname"],
                                  position: results[0].geometry.location
                              });
  
  
                              var myWindowOptions = {
                                  content:
                                      '&lt;h3&gt;'+p["lastname"] + " " + p["firstname"]+'&lt;/h3&gt;'+
                                      '&lt;p&gt;'+p["address"]
                              };
  
                              var myInfoWindow = new google.maps.InfoWindow(myWindowOptions);
  
                              google.maps.event.addListener(marker, 'click', function() {
                                  myInfoWindow.open(map,marker);
                              });
                      });
                  }
              }
  
   &lt;/script&gt;
  </code></pre>
  
  <p>I realy hope somebody can show me my mistake(s) and thanks a lot for help !! </p>
  
  <hr>
  
  <p>No, I really don't understand, 
  It should be something I didn't see in my code : </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
              var map;
              var geocoder;
              $(document).ready(function() {
                  initializeMap();
              });
  
  
              function initializeMap() {
  
                  var people = [{"userid":"47","lastname":"lastname1","firstname":"firstname1","address":"SomeAddress","phone1":"00000000000","phone2":"","email":"me@me.com"},{"userid":"42","lastname":"lastname2","firstname":"firstname2","address":"SomeAddress2","phone1":"0","phone2":"0","email":"me@me.com"}]; 
  
  
                  var center = new google.maps.LatLng(50.833, 25.000); 
  
                  var myOptions = {
                      zoom: 8,
                      center: center,
                      mapTypeId: google.maps.MapTypeId.ROADMAP
                  };
  
                  map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
                  geocoder = new google.maps.Geocoder();
  
  
  
                  var infowindow = new google.maps.InfoWindow();
  
                  var marker, i;
  
                  for (i = 0; i &lt; people.length; i++) {  
                      alert(people[i]['address']);
                      geocoder.geocode( { 'address': people[i]["address"]}, function(results, status) {
  
                          marker = new google.maps.Marker({
                              position: results[0].geometry.location,
                              map: map
                          });
  
                          google.maps.event.addListener(marker, 'click', (function(marker, i) {
                              return function() {
                                  infowindow.setContent('&lt;h3&gt;'+people[i]["lastname"] + " " + people[i]["firstname"]+'&lt;/h3&gt;');
                                  infowindow.open(map, marker);
                              }
                          })(marker, i));
                      });
                  }
  
              }
  &lt;/script&gt;
  </code></pre>
  
  <p>Thanks for help !! :)</p>