iOS Question Drawing lines on google map

stevenindon

Active Member
Licensed User
Hello all,

I have been using the code below to draw lines to googlemap in B4A successfully. But with B4i, I manage to add marker.. but the lines doesn't seems to appear.

B4X:
Public Sub GotoParis
    Dim cp As CameraPosition
    cp.Initialize2(48.8566, 2.3522,17.3,80,90)
    gmap.MoveCamera(cp)
    gmap.AddMarker(48.8566,2.3522,"FIRST POINT!!!")
    gmap.AddMarker(48.8566,2.3622,"SECOND POINT!!!")
    gmap.AddMarker(48.8580,2.3622,"THIRD POINT!!!")
    'CREATE LINE
    Dim line As Polyline
    Dim Allpoints As List
    Dim point As LatLng
    line=gmap.AddPolyline
    Allpoints.Initialize
    line.Color=Colors.Red
    line.Geodesic=True
    line.Width=15
    point.Initialize(48.8566, 2.3522)
    Allpoints.Add(point)
    point.Initialize(48.8566, 2.3622)
    Allpoints.Add(point)
    point.Initialize(48.8580, 2.3622)
    Allpoints.Add(point)
    line.Points=Allpoints
End Sub
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Don't assume that calling Initialize creates a new object. In this case you are adding the same point multiple times. You can add Dim point As LatLng before calling Initialize, though it is nicer to use:

B4X:
Private Sub CreatePoint(Lat As Double, Lon As Double) As LatLng
 Dim ll As LatLng
 ll.Initialize(Lat, Long)
 Return ll
End Sub

Allpoints.Add(CreatePoint(...))
Allpoints.Add(CreatePoint(...))
Allpoints.Add(CreatePoint(...))
 
Upvote 0
Top