c# - Combine content for multiple markers in one infobox in google maps through Asp.net -


I am working with google map in asp.net in SQL Server 2008. I have several records for the same latitude and longitude, instead of showing several pins, I would like to display a pins on top of the pin and in Infobox to display the content from those pins.

Here is my javascript code:

  window.onload = function () {var infoWindow = new google.maps.InfoWindow (); Var map = new google.maps.Map (document.getElementById ("dvMap"), map options); {Var data = marker [i] var myLatlng = new google.maps.LatLng (data.lat, data.lng) for (I = 0; i & lt; marker; langti; i ++); Var marker = new google.maps.marker ({status: myLatlng, map: map, icon: 'marker page', title: datatylet, 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 "& Quot; + data.description + '& lt; / div & gt;'); infoWindow.open (map, marker);})}} (marker, data);}}   

Here is the ASP.NET code:

  var marker = [& lt; asp: repeater id = "rptmarkers" runat = "server"> gt; item item & gt; ; {"Title": '& lt;% # Eval ("component")%>,' lat :: '<% # Eval ("latitude")%>,' lng ": '& Lt;% # Eval ("longitude")% & gt;', 'description ":' & lt;% # Eval (" component ")%> '+" "+' & lt;% # Eval ("Project_No")%> gt; & lt; / itememplate & gt; & lt; Sep AratorTemplate & gt;, & lt; / SeparatorTemplate & gt; & lt; / ASP: Repeater & gt; · Protected Zero Page_load (Object Sender, EventArgse E) {If (! This postback!) (DataTableDT = this.GetData ("Graph referrals"); RptMarkers.DataSource = dt; rptMarkers.DataBind ();}} Private datatable GetData (string query) {string conString = ConfigurationManager.ConnectionStrings ["constr"]. ConnectionString; SqlCommand CMD = New SQL Commands (Query); Cmd.CommandType = CommandType.StoredProcedure; Cmd.Parameters.AddWithValue ("year", 0); (Using SqlConnection con = new SqlConnection (conString)) (SqlDataAdapter sda = new SqlDataAdapter ()) {cmd.Connection = con; Sda.SelectCommand = cmd; (Datatelle dt = new datatile ()) using {sda.Fill (dt); Return DT; }}}}}    

As you are looping on markers, each marker To an array

Before creating each marker, check the array to make sure that these coordinates are not already markers.

If so, update the marker's description (or add new value) in the array to include a description of this duplicate location.

PS, this is not > javascript code ': & lt; Asp: repeater id = "rptmarkers" runat = "server" & gt;

Comments

Popular posts from this blog

c# - Textbox not clickable but editable -

Matlab transpose a table vector -

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -