title: Google Map API - infowindow in foreach loop
body: <p>Hello I'm retrieving data from SqlServerCe so I created foreach loop to create markers - that works it creates multiple markers but now I wanted to add to each of these marker an infowindow. But now whenever I click on marker the infowindow pops-up on the lastly created marker. </p>
  
  <pre><code>&lt;script&gt;
  function initialize() {
      var mapProp = {
          center:new google.maps.LatLng(51.508742,-0.120850),
          zoom:5,
          mapTypeId:google.maps.MapTypeId.ROADMAP
      };
      var map=new google.maps.Map(document.getElementById("googleMap")
        , mapProp);
  
      $(function () {
   @foreach (var row in data)
   {
     &lt;text&gt;
          var marker = new google.maps.Marker({ position: new google.maps.LatLng(@row.GeoLat,  @row.GeoLong),
              map: map });
  
          marker.info = new google.maps.InfoWindow({
              content: "test"
          });
  
          google.maps.event.addListener(marker, 'click', function() {
              marker.info.open(map, marker);
          });
  
          &lt;/text&gt;
  
  
   }
      });
  }
  
  
  
  google.maps.event.addDomListener(window, 'load', initialize);
  </code></pre>
  
  <p></p>
  
  <p>May someone help me with adding infowindow to each created markers?</p>
  
  <p>Thank you for your responding and your time.</p>
  
  <p>This is how I load from SqlServerCe</p>
  
  <pre><code>var db = Database.Open("StarterSite");
  
  var data = db.Query("SELECT DescriptionService,GeoLong,GeoLat FROM services");
  var array = new []{data} ;
  </code></pre>