Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invoking Google Map Applications from an Android application to get dirving direction


I need to show the driving direction using external google map application i found this link http://developer.android.com/guide/appendix/g-app-intents.html ,but the below opens the Maps application to the given location

    Uri uri = Uri.parse("geo:13.070984,80.253639");
    Intent in = new Intent(Intent.ACTION_VIEW, uri);
    startActivity(in);

I need to know is there is any way to pass two geo location to get driving direction.

like image 699
ganesh Avatar asked Dec 13 '22 14:12

ganesh


1 Answers

yes its very easy to show the direction if you have the latitude and longitude of both source and destination. Just see the following code:

Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
    Uri.parse("http://maps.google.com/maps?saddr="+latitude_source+","+longitude_source+"&daddr="+latitude_dest+","+longitude_dest));

    startActivity(intent);

Where latitude_source=Latitude of your source longitude_source=Longitude of your source latitude_dest=Latitude of your destination longitude_dest=Longitude of your destination

Just replace these value with your actual data. .Use the above code on some particular event.

Hope this will help you.

like image 153
Dinesh Sharma Avatar answered May 30 '23 00:05

Dinesh Sharma