Android Question Need to pass location (lat,long) to "Maps App" in mobile

Adamdam

Active Member
Licensed User
Longtime User
Dear all,
Greetings,

Need to pass location (lat, long) to "Maps App" in mobile to direct navigation to this location.
Ex: when you hit on WhatsApp-message (that contain location) the WhatsApp open other App (Maps in this case) and pass location to this App (Maps - App).
I need to make like this

notes: I don't need to open location inside my app (that require permission and so-on ) - so I need to open other app (i.e. Maps) to handle view and navigation and so-on.

Thanks on advance.
Best regards
 

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
The following code , taken from a working app, will navigate to a point from your current location using google maps

B4X:
Sub NavigatetoLatLong(Lat As String, Lng As String)
    Dim mapIntent As Intent
    Dim gURI As String
    gURI="google.navigation:q=" & Lat & "," & Lng
     
    mapIntent.Initialize(mapIntent.ACTION_VIEW, gURI)
    mapIntent.SetComponent("googlemaps")
    StartActivity(mapIntent)
   
End Sub

you can get other intents here:

the one you need is "GEO"

 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
other:
B4X:
Public Sub ShowPointsInMap(Latitude As Double, Longitude As Double)
    Dim GoogleMapIntent As Intent
    GoogleMapIntent.Initialize(GoogleMapIntent.ACTION_VIEW, $"http://maps.google.com/maps?q=${Latitude},${Longitude}"$)
    GoogleMapIntent.SetComponent("android/com.android.internal.app.ResolverActivity")
    StartActivity(GoogleMapIntent)
End Sub
 
Upvote 0

Adamdam

Active Member
Licensed User
Longtime User
The following code , taken from a working app, will navigate to a point from your current location using google maps

B4X:
Sub NavigatetoLatLong(Lat As String, Lng As String)
    Dim mapIntent As Intent
    Dim gURI As String
    gURI="google.navigation:q=" & Lat & "," & Lng
    
    mapIntent.Initialize(mapIntent.ACTION_VIEW, gURI)
    mapIntent.SetComponent("googlemaps")
    StartActivity(mapIntent)
  
End Sub

you can get other intents here:

the one you need is "GEO"


Really, many thanks Mr. Andrew for you,
The code work well,
Many thanks
 
Upvote 0

Adamdam

Active Member
Licensed User
Longtime User
other:
B4X:
Public Sub ShowPointsInMap(Latitude As Double, Longitude As Double)
    Dim GoogleMapIntent As Intent
    GoogleMapIntent.Initialize(GoogleMapIntent.ACTION_VIEW, $"http://maps.google.com/maps?q=${Latitude},${Longitude}"$)
    GoogleMapIntent.SetComponent("android/com.android.internal.app.ResolverActivity")
    StartActivity(GoogleMapIntent)
End Sub
Really, many thanks Sir for you,
The code also worked well,
Many thanks
 
Upvote 0
Top