I have an app that displays a map with a marker. When the user touches the marker I want to start navigation for them.
Is there an Intent/Activity that I can pass a longitude and latitude and start theusers navigation app?
Thanks for any help.
I have an app that displays a map with a marker. When the user touches the marker I want to start navigation for them.
Is there an Intent/Activity that I can pass a longitude and latitude and start theusers navigation app?
Thanks for any help.
I solved it like this. The url posted is similar.
Intent navigation = new Intent(
Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?saddr=START_LAT,START_LON&daddr=END_LAT,END_LON"));
startActivity(navigation);
Where Start is the START_LON and START_LAT is the longitude and latitude and END_LON, END_LAT is the end
That works fine:
googleMap.setMyLocationEnabled(true);
LocationManager locManager = (LocationManager) getSystemService(LOCATION_SERVICE);
Criteria cri = new Criteria();
bestProvider = locManager.getBestProvider(cri, true);
Location loc = locManager.getLastKnownLocation(bestProvider);
String latMy = String.valueOf(loc.getLatitude());
String lngMy = String.valueOf(loc.getLongitude());
Toast.makeText(this, "Navigation", Toast.LENGTH_SHORT).show();
String url = "http://maps.google.com/maps?saddr=" + latMy + ","
+ lngMy + "&daddr=" + "18.7703500,19.4534500";
Intent navigation = new Intent(Intent.ACTION_VIEW);
navigation.setData(Uri.parse(url));
startActivity(navigation);
Use :
Uri gmmIntentUri = Uri.parse("google.navigation:q="+"18.7703500,19.4534500");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);