How to plot a route using maps API

Asked

Viewed 1,266 times

3

I’m making an app in Android Studio for an event and would like that:

When opening a specific screen, the app would use the mobile gps to acquire the source coordinates and open the google maps app to create a route with the destination point at the event location.

from now on, thank you

1 answer

2


Welcome!

Try it this way:

 // URL para abrir o google maps
final String ulrRoute = "https://maps.google.com?saddr=Current+Location&daddr=%s,%s";

// Informe a latitude e longitude do local do evento
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse( String.format(Locale.getDefault(),ulrRoute, "-25.429138", "-49.271481") ));

// Informamos que queremos abrir a  Activity MapsActivity do com.google.android.apps.maps
i.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");

startActivity(i);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.