Android Question Polyline not draw - google maps - SOLVED

Discussion in 'Android Questions' started by daniedb, Jun 6, 2015.

  1. daniedb

    daniedb Active Member Licensed User

    Hi Guys,
    Spending 2 hours try to find this simple problem.
    Loading various point from a Listview - work
    add Markers to map - Work
    Add Point but they don't draw a line
    Please advice
    Code:
    gmap = mFragment.GetMap
             gmap.AddMarker(coordlistlat.GetItem(
    0),coordlistlon.GetItem(0) , "Departure/Take Off "&routeplaningList.GetItem(0))
               
    Log("1-  gmap add marker "&coordlistlat.GetItem(0)&" , "&coordlistlon.GetItem(0))
             
    Dim line As Polyline
             
    Dim ppoints As List
             
    Dim Point As LatLng
             line=gmap.AddPolyline
             ppoints.Initialize

            line.color=
    Colors.Red 'Array As Int(255,255,255)
            line.Geodesic=True
            line.Visible =
    True
            line.Width=
    15
            line.Points.AddAll(ppoints)
             
    For i = 0 To routeplaningList.size -1
                
    Point.Initialize(coordlistlat.GetItem(i),coordlistlon.GetItem(i))
                   ppoints.Add(
    Point)
               
    Log("Point.Initialize("&coordlistlat.GetItem(i)&" , "&coordlistlon.GetItem(i)&" ")
                 gmap.AddMarker(coordlistlat.GetItem(i),coordlistlon.GetItem(i) , routeplaningList.GetItem(i))
           
    Next
                   
    Log(ppoints.Size)
                 
    Dim cp As CameraPosition
              cp.Initialize(coordlistlat.GetItem(
    0),coordlistlon.GetItem(0) , 12)
               
    Log ("1 - cp initialized  after gmap "&coordlistlat.GetItem(0)&" , "&coordlistlon.GetItem(0))
               gmap.AnimateCamera(cp)
    THanks
    D
     
  2. daniedb

    daniedb Active Member Licensed User

    Forgot to add line.points=ppoints
     
    eurojam likes this.
  3. eurojam

    eurojam Well-Known Member Licensed User

    it seems that your ppoints is empty when you add it to the line...you fill ppoints after adding to the polyline...may be that the reason??
     
  4. daniedb

    daniedb Active Member Licensed User

    Yes eurojam, I forgot to add the ppoint after all the points has been populated/initialized
    Stupid mistake that took me 2 hours to sort out... wasted time...
     
Loading...