troubleshooting Question

google maps multiple points marker

Avatar of dmiebim
dmiebimFlag for Turkey asked on
Microsoft DevelopmentEditors IDEsWeb Applications
4 Comments1 Solution4732 ViewsLast Modified:
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
ASKER CERTIFIED SOLUTION
mmarx82

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros