Overlays

Jun 5, 2009 at 4:01 PM

Hello,

I've a problem with the new overlays. I have a huge list of points, which should display several regions in the Netherlands. I have a vb app, but translated the code in C# also, neither works the right way.

        Dim Ov As New GMapNET.GMapOverlay(mainmap, "Regiolijntjes")
        mainmap.Overlays.Add(Ov)
        Dim Regio = My.Resources.RegioLijntjes.Split("y")
        Dim Points As New List(Of GMapNET.PointLatLng)
        For i = 0 To 20
            Points.Clear()
            Dim RegioPoints = Regio(i).Split("/")
            For ii = 0 To RegioPoints.Length - 1
                Dim tmp = RegioPoints(ii).Split("x")
                If tmp(0) <> "" Then
                    Points.Add(New GMapNET.PointLatLng(tmp(0).Replace(".", ","), tmp(1).Replace(".", ",")))
                End If
            Next
            Dim Lines As New GMapNET.GMapRoute(Points, "Regiolijntjes")
            Lines.Color = Color.Red
            Ov.Routes.Add(Lines)
        Next
        Regio = Nothing
        Ov.IsVisibile = My.Settings.LinesEnabled

With that, Ov has correctly 25 routes. But he draws only the last one! Have you any idea how this is possible?
The points are seperated by "/", the coordinates by "x", and the regions by "y".

With kind regards,
Thomas

Jun 5, 2009 at 5:10 PM

maybe not so corectly ;} try manual add few routes

Jun 5, 2009 at 8:28 PM

Aah, got it. I shouldn't have cleared the Points list. It still affects the Lines, and thereby, still the Ov.Routes variable. Strange, but ok. Code should be this:

        Dim Ov As New GMapNET.GMapOverlay(mainmap, "Regiolijntjes")
        mainmap.Overlays.Add(Ov)
        Dim Regio = My.Resources.RegioLijntjes.Split("y")
        For i = 0 To Regio.Count - 1
            Dim Points As New List(Of GMapNET.PointLatLng)
            Dim RegioPoints = Regio(i).Split("/")
            For ii = 0 To RegioPoints.Length - 1
                Dim tmp = RegioPoints(ii).Split("x")
                If tmp(0) <> "" Then
                    Points.Add(New GMapNET.PointLatLng(tmp(0).Replace(".", ","), tmp(1).Replace(".", ",")))
                End If
            Next
            Dim Lines As New GMapNET.GMapRoute(Points, "Regiolijntjes")
            Lines.Color = Color.Red
            Ov.Routes.Add(Lines)
        Next
        Regio = Nothing
        Ov.IsVisibile = My.Settings.LinesEnabled

Thanks!

Jun 5, 2009 at 8:30 PM

welcome ;}