Android Question draw direction between 2 points on map -google direction api

samar magdy

New Member
I want to draw the rout between two points on google maps but I found that I need to use google direction api and I don't know how to use it in b4a

here is my code can any one edit this code so i could draw the rout between for example these 2 points
(29.956333, 31.252003)
(29.957596, 31.256037)
B4X:
#Region  Project Attributes
   #ApplicationLabel: map Example
   #VersionCode: 1
   #VersionName:
   'SupportedOrientations possible values: unspecified, landscape or portrait.
   #SupportedOrientations: unspecified
   #CanInstallToExternalStorage: False
    #AdditionalJar: com.google.android.gms:play-services-maps

#End Region

#Region  Activity Attributes
   #FullScreen: False
   #IncludeTitle: True
#End Region

'Activity module
Sub Process_Globals


   
End Sub

Sub Globals
    Private gmap As GoogleMap
    Private MapFragment1 As MapFragment
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    If MapFragment1.IsGooglePlayServicesAvailable = False Then
        ToastMessageShow("Please install Google Play Services.", True)
    End If
End Sub
Sub Wait(Sekunden As Int)
    Dim Ti As Long
    Ti = DateTime.Now + (Sekunden * 1000)
    Do While DateTime.Now < Ti
        DoEvents
    Loop
End Sub
Sub MapFragment1_Ready
    gmap = MapFragment1.GetMap
   
    Private loc As LatLng
    Wait ( 3)
          loc=gmap.MyLocation
       
          Dim myLatitude As Double = loc.Latitude
    Dim myLongitude As Double = loc.Longitude
    Dim m1 As Marker = gmap.AddMarker(myLatitude,myLongitude, "test")
   
    Dim cp As CameraPosition
    cp.Initialize(myLatitude,myLongitude,17)
    gmap.AnimateCamera(cp)
    m1.Snippet = "This is the snippet"
    gmap.TrafficEnabled = True

   
   
   
End Sub
I used google-services json and google map library that was in the tutorial
 
Top