Android Tutorial Showing Google turn by turn

Hi,

Below some sample code to show directly Turn by Turn navigation instead of map:

Sub ShowNavigation (Latitude As String,Longitude As String)
'google place, just show map
Dim mapIntent As Intent
Dim geoURI As String
geoURI="google.navigation:q=" & Latitude & "," & Longitude
mapIntent.Initialize(mapIntent.ACTION_VIEW,geoURI)
mapIntent.SetComponent("googlemaps")
StartActivity(mapIntent)
End Sub

I use this in a static module.

Have fun!
 

warwound

Expert
Licensed User
Longtime User
Thanks.

That will come in very handy for an app i'm working on right now :sign0060:.

Martin.
 

rbsoft

Active Member
Licensed User
Longtime User
Thanks a lot BlueDude! That came in very handy.

I toyed around with it and slightly modified your routine to navigate to a street adress rather than coordinates:

B4X:
Sub NavigateToStreetAdress (sAdress As String)
   Dim mapIntent As Intent 
   Dim geoURI As String
   
   geoURI="google.navigation:q=" & sAdress
   mapIntent.Initialize(mapIntent.ACTION_VIEW,geoURI)
   mapIntent.SetComponent("googlemaps")
   StartActivity(mapIntent)
End Sub

sAdress should contain Street and No, City, ZipCode

Example:
sAdr = "Rosenbaumweg 42,Bochum,44805"
(That's a German adress.)
 

Attachments

  • Navigate.zip
    211.4 KB · Views: 1,199
Last edited:

Fox

Active Member
Licensed User
Longtime User
Thanks a lot BlueDude! That came in very handy.

I toyed around with it and slightly modified your routine to navigate to a street adress rather than coordinates:

B4X:
Sub NavigateToStreetAdress (sAdress As String)
   Dim mapIntent As Intent 
   Dim geoURI As String
   
   geoURI="google.navigation:q=" & sAdress
   mapIntent.Initialize(mapIntent.ACTION_VIEW,geoURI)
   mapIntent.SetComponent("googlemaps")
   StartActivity(mapIntent)
End Sub

sAdress should contain Street and No, City, ZipCode

Example:
sAdr = "Rosenbaumweg 42,Bochum,44805"
(That's a German adress.)

wow very nice sample thank you for posting. But here is my question about the location find ... is it possible to readout the current location with streetname and show it on the map? It must be work with gps location or?
 

rbsoft

Active Member
Licensed User
Longtime User
... is it possible to readout the current location with streetname and show it on the map? It must be work with gps location or?

Getting Latitude and Longitude is easily done with the Gps library. (See example http://www.b4x.com/forum/basic4android-getting-started-tutorials/6592-gps-tutorial.html).

Showing that location on a map is also no problem.

To get a street adress from the coordinates (reverse geocoding) you probably would need to use Google's geocode service This might be an interesting link for it: Google Geo Developers Blog: Geocoding... in Reverse!

Rolf
 

rbsoft

Active Member
Licensed User
Longtime User
I added an updated sample that uses Gps.Location to display the coordinates and show the position in GoogleMaps via intent.

(Code is borrowed in part from the Gps Tutorial.)
 

Attachments

  • Navigate2.zip
    8.1 KB · Views: 928

cmweb

Active Member
Licensed User
Longtime User
Hello,

thanks for this thread, that showed me the way to launch Google Navigation from my App.

One additional thing:

If you like to start a walking navigation, the line needs to look like this:

geoURI="google.navigation:ll=" & Latitude & "," & Longitude & "&mode=w"

Best regards,

Carsten
 

customnames

Member
Licensed User
Longtime User
I have this working Ok and would like to expand on it by adding another destination or waypoint
How would I go about this
also how do you get a list of intents for apps any light reading would help
Thanks
 

COBRASoft

Active Member
Licensed User
Longtime User
I'm interested in this too. For our app, it would be handy if we could show a complete route to the user. It would also be nice if we could show a time by each destination so the user knows when he has to be there. Is this possible with B4A?
 

Smee

Well-Known Member
Licensed User
Longtime User
Bluedude & Rbsoft,
Thanks for sharing your work. I will be using this to develop an in-house app. I will be watching this thread for any ideas. It shows how easy it is when you know how.:sign0188:


Thanks Again

Joe
 

rbsoft

Active Member
Licensed User
Longtime User

Smee

Well-Known Member
Licensed User
Longtime User
I use a xoom and i came across this question

Xoom GPS quick question?? - Page 2

It seems that a route could be planned before setting out and the position of the device updated without wifi or internet connection. Is this possible? If so how could the map cache be saved? anyone have any ideas?

Joe
 

rildomoraes

Member
Licensed User
Longtime User
Sygic Fleet SDK

I'm interested in this too. For our app, it would be handy if we could show a complete route to the user. It would also be nice if we could show a time by each destination so the user knows when he has to be there. Is this possible with B4A?

Sygic Fleet SDK is solution, but is not open source. :sign0148:
 

eps

Expert
Licensed User
Longtime User
Thanks a lot BlueDude! That came in very handy.

I toyed around with it and slightly modified your routine to navigate to a street adress rather than coordinates:

B4X:
Sub NavigateToStreetAdress (sAdress As String)
   Dim mapIntent As Intent 
   Dim geoURI As String
   
   geoURI="google.navigation:q=" & sAdress
   mapIntent.Initialize(mapIntent.ACTION_VIEW,geoURI)
   mapIntent.SetComponent("googlemaps")
   StartActivity(mapIntent)
End Sub

sAdress should contain Street and No, City, ZipCode

Example:
sAdr = "Rosenbaumweg 42,Bochum,44805"
(That's a German adress.)

Fantastic, just used this. Straight out of the box it worked! Thankyou!!

:)
 

aptinis7

Member
Licensed User
Longtime User
can some one post the androidmanifest.xml

:sign0085:Can someone post the androidmanifest.xml file ? i know that i have to change this file but i dont what exactly to change?
 

rbsoft

Active Member
Licensed User
Longtime User
I don't see any need to change the manifest file. Did you have something special in mind or do you run into any problem?

Rolf
 

Mossy69b4a

New Member
Licensed User
Longtime User
Fantastic job,
i have a little question ?

once navigation lauched and i press the back button i get the message "Exit Navigation / this will end route guidance".
is it possible to prevent this and instead put the guidance in the background ?

thanks for your help
 
Last edited:

AlteregoHR

Member
Licensed User
Longtime User
Hello,
Is there a way of specifiing strating point? These examples use destination adress and current location.
Thanks,
 

rbsoft

Active Member
Licensed User
Longtime User
This would show a route between two coordinates. The routine will ask if you want to use the browser or the maps application. Works in both.

B4X:
Sub CalcRoute()
    Dim mapIntent As Intent
    Dim geoURI As String
    Dim Lat1,Lat2,Lon1,Lon2 As String
  
    Lat1 = "51.12345"
    Lon1 = "6.12345"
    Lat2 = "51.54321"
    Lon2 = "6.54321"
  
    geoURI="http://maps.google.com/maps?saddr=" & Lat1 & "," & Lon1 & "&daddr=" & Lat2 & "," & Lon2
    mapIntent.Initialize(mapIntent.ACTION_VIEW,geoURI)
    mapIntent.SetComponent("googlemaps")
    StartActivity(mapIntent)
End Sub

Rolf
 
Top