title: How to create multiple infowindow in google map api
body: <p>I create 3 markers in the map whose data comes from a json. but when I click on a marker and try to open the Info window only the last marker will response correctly.. please help me.... this the code....</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;  
      &lt;script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="js/jquery-1.8.3.min.js"&gt;&lt;/script&gt;
      &lt;script src="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/src/markerclusterer.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;script&gt;
          var json = [
              {
                  "title": "Stockholm",
                  "lat": 59.3,
                  "lng": 18.1,
                  "description": "Stockholm is the capital and the largest city of Sweden and constitutes the most populated urban area in Scandinavia with a population of 2.1 million in the metropolitan area (2010)"
              },
              {
                  "title": "Oslo",
                  "lat": 59.9,
                  "lng": 10.8,
                  "description": "Oslo is a municipality, and the capital and most populous city of Norway with a metropolitan population of 1,442,318 (as of 2010)."
              },
              {
                  "title": "Copenhagen",
                  "lat": 55.7,
                  "lng": 12.6,
                  "description": "Copenhagen is the capital of Denmark and its most populous city, with a metropolitan population of 1,931,467 (as of 1 January 2012)."
              }
          ]
          var myCenter=new google.maps.LatLng(51.508742,-0.120850);
          function initialize()
          {
              var mapProp = {
                  center:myCenter,
                  zoom:5,
                  mapTypeId:google.maps.MapTypeId.ROADMAP
              };
              var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
              for (var i = 0, length = json.length; i &lt; length; i++) {
                  var data=json[i];
                  var latLng = new google.maps.LatLng(data.lat, data.lng); 
                  // Creating a marker and putting it on the map
                  var marker = new google.maps.Marker({
                      position: latLng,
                      map: map,
                      title: data.title
                  });
              } 
                  var infowindow = new google.maps.InfoWindow({
                      content: data.description
                  });
  
              google.maps.event.addListener(marker, 'click', function() {    
                  infowindow.open(map,marker);
              });
  
          }
          google.maps.event.addDomListener(window, 'load', initialize);
      &lt;/script&gt;
      &lt;div id="googleMap" style="width:100%;height:100%;"&gt;&lt;/div&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>