Question

I'm using google map v2 for showing locations in my application. When I want to navigate to that particular location I use the following code which starts the default navigation application installed in my phone.

Intent navigation = new Intent(Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?saddr=aa,bb&daddr=xx,yy"));
startActivity(navigation);

So obviously we will leave our application and go to the default navigation application. Is there any chance that I can do the turn-by-turn navigation within the google map which is to be shown in my application itself?

Was it helpful?

Solution

Is there any chance that I can do this navigation within the google map which is shown in my application itself?

Unfortunately no. Google does not expose turn-by-turn navigation engine, so the maximum you can get with Google Map V2 is display route using route points returned from Route API. Actual turn-by-turn needs to be done via proprietary Google Navigation app

OTHER TIPS

Yes you can display map in our application using MapFragment. Below is an example for such a activity inside which you can add the mapfragment.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >    

     <fragment 
          android:id="@+id/fragmap"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:name="com.google.android.gms.maps.MapFragment" />

</LinearLayout>

EDIT: for directions use this-

Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
                Uri.parse("http://maps.google.com/maps?saddr="
                + destLat + ","
                + destLong + "&daddr="
                + srcLat + "," + strLong));
startActivity(intent);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top