Android Question Polyline not draw - google maps - SOLVED

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
B4X:
         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
 

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??
 

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...
 
Top