Reimers.dk

.NET, AJAX and Google APIs brought together
Welcome to Reimers.dk Sign in | Join | Help
in Search

How to make that polyline to show up on the map ??????????????????????? F*CK !!!

Last post 01-02-2010, 19:20 by jjrdk. 1 replies.
Sort Posts: Previous Next
  •  12-30-2009, 12:27 2929

    How to make that polyline to show up on the map ??????????????????????? F*CK !!!

    Hi I am getting frustrated here,  can anyone spot what I am doing wrong here. I can't update the reimers GoogleMAP control with my polyline ? What code is missing to get that damn controll to
    redraw the map with my database content ? 

    Best regards 
     
    Janne
     
     
    Dim poly As New GooglePolyline
            Dim strPoly As String
            Dim lat As String = ""
            Dim lng As String = ""
            Dim index As Integer

            Dim con As New SqlConnection("Data Source=Janne-HPNEW;Initial Catalog=GPSGate;Persist Security Info=True;User ID=sa;Password=Ramses12")

            con.Open()

            Dim cmd As New SqlCommand("SELECT * FROM dbo.A1 WHERE speed > '10' ORDER BY time", con)

            Dim result As SqlDataReader = cmd.ExecuteReader
            
            While result.Read
                lat = result("Latitude").ToString() / 100000
                lng = result("Longitude").ToString() / 100000
                poly.Points.Add(New GoogleLatLng(lat, lng))

    ' Below row is just for testing to se that the database is looping trouch the records.  And it does !!!!          
    TextBox6.Text = TextBox6.Text + lat & " " & lng + Chr(10) + Chr(13)

            End While


            result = Nothing
            con.Close()
            con = Nothing

            poly.Width = 8
            poly.Color = Drawing.Color.Black
            poly.Opacity = 0.5

            Map.AddOverlay(poly)
            Map.UpdateOverlays()


  •  01-02-2010, 19:20 2932 in reply to 2929

    Re: How to make that polyline to show up on the map ??????????????????????? F*CK !!!

    I would almost expect the code you posted to throw an exception. You are trying to pass strings where the constructor expects double values. This may work in VB because it converts the values automatically for you. But if you are using a language where the decimal separator is different from the expected (i.e. using comma instead of point) then an error may be thrown. I would suggest that you used doubles for lat and lng.

    Another problem is the call to AddOverlay. If you read the documentation then you will see that it generates a JavaScript command. However you are not assigning this command to anything. If this code is run in an event handler then assign it to the map command:

    e.MapCommand = Map.AddOverlay(poly, true)

    if it is run in page load, then simply add the line to the overlays collection.

    Map.Overlays.Add(poly) 

View as RSS news feed in XML