0

I want to draw routes on Google Maps (walk or drive), I want to give intent the current user coordinates and the destination coordinates, to draw and navigate the route, as this image

enter image description here

I used this code

Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?saddr=20.344,34.34&daddr=20.5666,45.345")); startActivity(intent);

but I got "No route found"

Thanks a lot

JustMe
  • 732
  • 1
  • 11
  • 16

1 Answers1

1

You can't do that with intent. You should use JSON request with http://maps.googleapis.com/maps/api/directions/output?parameters. If you use JSON request, you must make it like this example, just add your coordinates : String url = "http://maps.googleapis.com/maps/api/directions/json?origin="yourlat","yourlong"&destination="secondlat","secondlong"&sensor=false";

This may help: Android draw route on a Mapview with twoo POI-s and this How do I draw a KML file on a MapView in Android?

Community
  • 1
  • 1
androidEnthusiast
  • 1,140
  • 1
  • 12
  • 21