google maps multiple points marker

Hi all;

How to view messages for each point separately.
points comes from the database dynamically (multiple points)

My code (vb.net code behind)

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            Try
                Dim myGoogleMap As New StringBuilder
                myGoogleMap.Append("<script src='http://maps.google.com/maps?file=api&v=2&key=**************'" + vbCrLf)
                myGoogleMap.Append("type='text/javascript'></script>" + vbCrLf)
                myGoogleMap.Append("<script type='text/javascript'>" + vbCrLf)
                myGoogleMap.Append(vbCrLf + vbCrLf)
                myGoogleMap.Append("var map = null;" + vbCrLf)
                myGoogleMap.Append("var mapObj = null;" + vbCrLf)
                myGoogleMap.Append("var geoCoder = null;" + vbCrLf)
                myGoogleMap.Append(vbCrLf + vbCrLf)
                myGoogleMap.Append("mapObj = document.getElementById('map');" + vbCrLf)
                myGoogleMap.Append("map = new GMap2(mapObj);" + vbCrLf)
                myGoogleMap.Append("geocoder = new GClientGeocoder();" + vbCrLf)
                myGoogleMap.Append("map.setCenter(new GLatLng(39.9725,32.8636), + 6);" + vbCrLf)
                'myGoogleMap.Append("map.setCenter(new GLatLng(" + coordinate + "), + 5);" + vbCrLf)

                Dim dv As DataView = CType(sqlTesisler.Select(DataSourceSelectArguments.Empty), DataView)
                Dim latitude As String = ""
                Dim Longitude As String = ""
                Dim place As String = ""
                Dim coordinate As String = ""


                For i = 0 To dv.Table.Rows.Count - 1
                    latitude = dv.Table.Rows(i).Item("latitude").ToString()
                    Longitude = dv.Table.Rows(i).Item("Longitude").ToString()
                    place = dv.Table.Rows(i).Item("Adi").ToString()
                    coordinate = Replace(latitude, ",", ".") & "," & Replace(Longitude, ",", ".")

                    myGoogleMap.Append("var point = new GLatLng(" + coordinate + ");" + vbCrLf)
                    myGoogleMap.Append("map.addOverlay(new GMarker(point));" + vbCrLf)
                   'point message
                   '???????????????????????????????????
                Next

                myGoogleMap.Append("map.addControl(new GSmallMapControl());" + vbCrLf)
                myGoogleMap.Append("map.addControl(new GMapTypeControl());" + vbCrLf)
                myGoogleMap.Append("GMap2.prototype.wheelZoom = function(event)" + vbCrLf)
                myGoogleMap.Append("{ if((event.detail || -event.wheelDelta) < 0)" + vbCrLf)
                myGoogleMap.Append("  { map.zoomIn();} else { map.zoomOut();}" + vbCrLf)
                myGoogleMap.Append("return false; " + vbCrLf)
                myGoogleMap.Append("} " + vbCrLf)

                myGoogleMap.Append("GEvent.addDomListener(mapObj, 'DOMMouseScroll', map.wheelZoom); " + vbCrLf)
                myGoogleMap.Append("GEvent.addDomListener(mapObj, 'mousewheel', map.wheelZoom);" + vbCrLf)
                myGoogleMap.Append("GEvent.addListener(map, 'click', function(marker, point) { map.setCenter(point); } ); " + vbCrLf + vbCrLf)

                myGoogleMap.Append("function showAddress(address) {" + vbCrLf)
                myGoogleMap.Append("  ;" + vbCrLf)
                myGoogleMap.Append("  alert ('In function')" + vbCrLf)
                myGoogleMap.Append("  geocoder.getLatLng(" + vbCrLf)
                myGoogleMap.Append("    address," + vbCrLf)
                myGoogleMap.Append("    function(point) {" + vbCrLf)
                myGoogleMap.Append("      if (!point) {" + vbCrLf)
                myGoogleMap.Append("        alert(address + ' not found');" + vbCrLf)
                myGoogleMap.Append("      } else {" + vbCrLf)
                myGoogleMap.Append("       map.setCenter(point, 13);" + vbCrLf)
                myGoogleMap.Append("        var marker = new GMarker(point);" + vbCrLf)
                myGoogleMap.Append("        map.addOverlay(marker);" + vbCrLf)
                myGoogleMap.Append("        marker.openInfoWindowHtml(address);" + vbCrLf)
                myGoogleMap.Append("      }" + vbCrLf)
                myGoogleMap.Append("    }" + vbCrLf)
                myGoogleMap.Append("  );" + vbCrLf)
                myGoogleMap.Append("}" + vbCrLf)

                myGoogleMap.Append("</script>")

                If (Not Me.ClientScript.IsStartupScriptRegistered("StartMap")) Then
                    Me.ClientScript.RegisterStartupScript(GetType(String), "StartMap", myGoogleMap.ToString())
                End If
            Catch ex As Exception
                txtDurum.Text = "Error : " & ex.Message
            End Try

        End If
    End Sub
googlemap.JPG
dmiebimAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mmarx82Commented:
Ok, I know my code is not .NET, it's classic asp but maybe it will help you get an idea.
My var "ps" defines all my locations in lat and long looping through my database and puts it in an array. When it finishes it goes back to the beginning of the recordset.
Afterwhich, the var "ls" starts a new array that contains my messages after clicked code.
The part that throws it all together is where you can see the ps and ls vars:
   for (var i = 0; i < <%=Counter%>; i++) {
     mrks[i] = createMarker(ps[i], ls[i], is[i]);
     
     map.addOverlay(mrks[i]);
   }
 The <%=Counter%> is what I used to make sure everything matched up when combining everything together. It may not have been the most efficient way to do it but with limited examples out there this is what works for me, besides I only had 15 locations to map.
Good luck and hope this gets your brain flowing.

		if (GBrowserIsCompatible()) {
			
			var i1 = new GIcon();
			i1.image = "images/gmarker.png";
			i1.iconSize = new GSize(20, 34);
			i1.iconAnchor = new GPoint(10, 34);
			// i1.shadow = "http://maps.yourgmap.com/m/s0.png";
			// i1.shadowSize = new GSize(1, 1);
			i1.infoWindowAnchor = new GPoint(10, 1);
			
		
			var map = new GMap2(document.getElementById("mymap"));
			
			
			map.addControl(new GLargeMapControl());
			map.addControl(new GMapTypeControl());
			//map.enableScrollWheelZoom()
			
			<% if strLocation <> "" then %>
				map.setCenter(new GLatLng(<%=rs.fields("Lat")%>,<%=rs.fields("Long")%>), 17,G_HYBRID_MAP);
			<% else %>
				map.setCenter(new GLatLng(31.8341075,-81.55426025), 12, G_HYBRID_MAP);
			<% end if %>
			
			var marker = 0;
		
			var mrks = new Array(<%=Counter%>);
			
			var ps = new Array(
			<% do while not rs.eof %>
			 		new GLatLng(<%=rs.fields("Lat")%>,<%=rs.fields("Long")%>)<%rs.movenext%><%if rs.eof <> "True" then%>,
			<%
				end if
				loop
				rs.movefirst
			%> 
			 );
			
			
			var ls = new Array(
			<%	Counter = 0				
				do while not rs.eof %>
				'<table><tr><td align="left"><strong><%=rs.fields("Location")%></strong><br /><%=rs.fields("Street")%><br /><%=rs.fields("City_State")%><%=rs.fields("Zip")%><br /><%=rs.fields("PhoneNumber")%><br /><%if rs.fields("Image") <> "" then %><br /><%end if%><br /><a href="<%=rs.fields("Website")%>" target="_top">View Website</a><br/>  <!--- <a href="">Take Virtual Tour</a><br/> -->  <a href="javascript:enableDirections(document.Loc<%=Counter%>.Lo<%=Counter%>.value,<%=rs.fields("Lat")%>,<%=rs.fields("Long")%>,<%=Counter%>)" target="_top">Get Directions to here</a></td><%if rs.fields("Image") <> "" then %><td><a href="<%=rs.fields("Website")%>" target="_top"><img src="<%=rs.fields("Image")%>"></a></td><%end if%></tr></table>'<%rs.movenext%><%if rs.eof <> "True" then%>,
			<%
				end if
				Counter = Counter + 1
				loop
				rs.movefirst
			%> 
			);
			
			
			
			var is = new Array(
			<% do while not rs.eof %>i1<%rs.movenext%><%if rs.eof <> "True" then%>,
			<%
				end if
				loop
				rs.close
				adoCon.close
			%> 
			 );
								

			
			for (var i = 0; i < <%=Counter%>; i++) {
			  mrks[i] = createMarker(ps[i], ls[i], is[i]);
			  
			  map.addOverlay(mrks[i]);
			}
			
			<% if strLocation <> "" then			' Means that there was user interaction from another page and a school was choosen %>
				mrks[0].openInfoWindowHtml(ls[0]);
			<% end if %>
			
		}

Open in new window

0
dmiebimAuthor Commented:

I tried but could not convert the code. (vb.net)
points appear. When I click the balloon message does not appear

thanks
0
mmarx82Commented:
you should probably do a Request Attention on this or close it altogether.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dmiebimAuthor Commented:
The offered solutions does not solve the problem
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.