Android Question Draw line in googlemap not shhowing

warayTek

Member
Licensed User
Hi, I need to draw a line between 2 points. I found a snippet but does not work for me.
B4X:
Sub LineTest
    Dim PointList As List
    PointList.Initialize
    gmap.Clear
    
    Dim Pt1 As LatLng
    Pt1.Initialize(11.2438762,125.0079656)
    Dim Pt2 As LatLng
    Pt2.Initialize(11.243402, 125.008711)
    PointList.Add(Pt1)
    PointList.Add(Pt2)
    gmap.AddMarker2(Pt1.Latitude,Pt1.Longitude,"Info1",gmap.HUE_MAGENTA)
    gmap.AddMarker2(Pt2.Latitude,Pt2.Longitude,"Info2",gmap.HUE_MAGENTA)
    
    
    Dim sPoly As Polyline = gmap.AddPolyline
    sPoly.Points.Add(Pt1)
    sPoly.Points.Add(Pt2)
    sPoly.Color=Colors.Blue
    sPoly.Width = 20dip
    Dim LLB As LatLngBoundsBuilder
    LLB.Initialize
    LLB.Include(Pt1)
    LLB.Include(Pt2)
    
    Dim LatLngBounds1 As LatLngBounds = LLB.Build
    GoogleMapsExtras1.AnimateToBounds2 (gmap, LatLngBounds1 , Activity.Width,Activity.height, 40)
End Sub

I appreciate any inputs.
 

Attachments

  • demo.png
    demo.png
    62 KB · Views: 76

Brian Dean

Well-Known Member
Licensed User
Longtime User
This subroutine draws a line between two points . . .
B4X:
Private Sub drawLine(p1 As LatLng, p2 As LatLng)
    Dim line As Polyline = gmap.AddPolyline
    line.Color = xui.Color_Red
    line.Width = 8
    Dim points As List
    points.Initialize
    points.Add(p1)
    points.Add(p2)
    line.Points = points
End Sub
 
Upvote 0
Top