Android Question Maps: Order of adding points to polyline

When adding a polyline to a google map fragment, what is the right order of things? I have a cycle computer app which wants to grow the polyline with each change of location.
At present I'm calling AddPolyline once, then adding points (LatLngs) to its points list as the location changes. But the polyline is not appearing.

Should I be calling a new AddPolyline (with 2 points, from previous location to new location) as the location changes? Or should it work to update the points list for an existing polyline?
 
I've tracked it down to a small change in how points are added to the polyline. I can get the polyline to appear if I add individual segments as separate polylines (called whenever location changes) like this:
B4X:
    Dim LL As LatLng
    Dim pts As List
    pts.Initialize
    Poly = gmap.AddPolyline
    Poly.Color = Colors.Blue

    LL.Initialize(prevLocation.Latitude, prevLocation.Longitude)
    pts.Add(LL)
    LL.Initialize(Location1.Latitude, Location1.Longitude)
    pts.Add(LL)
    Poly.Points = pts      ' add points all at once by copying the list

However, if I try to add the points directly into the Poly.Points list, one at a time, the polyline does not appear:
B4X:
    Dim LL As LatLng
    Poly = gmap.AddPolyline
    Poly.Color = Colors.Blue

    LL.Initialize(prevLocation.Latitude, prevLocation.Longitude)
    Poly.Points.Add(LL)       ' add points one at a time 
    LL.Initialize(Location1.Latitude, Location1.Longitude)
    Poly.Points.Add(LL)

The upshot of this is that I can't see any way to grow the polyline with nice clean joins by adding points to it one at a time. (unless I clear and re-add a new polyline each time, which I haven't tried yet)

Attached is the GoogleMaps example with GNSS location lookup and attempts to draw the polyline.
 

Attachments

  • MapsExampleWithPolyline.zip
    1.6 KB · Views: 2
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…