title: Combine content for multiple markers in one infobox in google maps through Asp.net
body: <p>I am working with google map in asp.net with Sql Server 2008. I have multiple records for same Latitude and Longitude. Instead of showing too many pins , I would like to display one pin and in the infobox above the pin to display the content from those multiple records.</p>
  
  <p>Here is my Javascript Code :</p>
  
  <pre><code>window.onload = function () {
          var infoWindow = new google.maps.InfoWindow();
          var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);
          for (i = 0; i &lt; markers.length; i++) {
              var data = markers[i]
              var myLatlng = new google.maps.LatLng(data.lat, data.lng);
              var marker = new google.maps.Marker({
                  position: myLatlng,
                  map: map,
                  icon: 'marker.png',
                  title: data.title,
                  animation: google.maps.Animation.DROP
              });
              (function (marker, data) {
                  google.maps.event.addListener(marker, "click", function (e) {
                      infoWindow.setContent('&lt;div style="width:250px;height:80px;background:red"&gt;' + data.description + '&lt;/div&gt;');
                      infoWindow.open(map, marker);
                  });
              })(marker, data);
          }
      }
  </code></pre>
  
  <p>Here is Asp.NET Code:</p>
  
  <pre><code>var markers = [
      &lt;asp:Repeater ID="rptMarkers" runat="server"&gt;
      &lt;ItemTemplate&gt;
                  {
                  "title": '&lt;%# Eval("Component") %&gt;',
                  "lat": '&lt;%# Eval("Latitude") %&gt;',
                  "lng": '&lt;%# Eval("Longitude") %&gt;',
                  "description": '&lt;%# Eval("Component") %&gt;'+" "+'&lt;%# Eval("Project_No") %&gt;'
              }
      &lt;/ItemTemplate&gt;
      &lt;SeparatorTemplate&gt;
          ,
      &lt;/SeparatorTemplate&gt;
      &lt;/asp:Repeater&gt;
      ];
  
      protected void Page_Load(object sender, EventArgs e)
          {
              if (!this.IsPostBack)
              {
                  DataTable dt = this.GetData("graphrepresentation");
  
                  rptMarkers.DataSource = dt;
                  rptMarkers.DataBind();
              }
          }
              private DataTable GetData(string query)
              {
                      string conString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
                      SqlCommand cmd = new SqlCommand(query);
                      cmd.CommandType = CommandType.StoredProcedure;
                      cmd.Parameters.AddWithValue("year",0);
                      using (SqlConnection con = new SqlConnection(conString))
                      {
                          using (SqlDataAdapter sda = new SqlDataAdapter())
                          {
                                  cmd.Connection = con;
                                  sda.SelectCommand = cmd;
                                  using (DataTable dt = new DataTable())
                                  {
                                      sda.Fill(dt);
                                      return dt;
                                  }
                          }
                      }
  
              }
  </code></pre>