Search code examples
androidgoogle-mapsroutesmylocationoverlay

Draw route by getting my point to destination point


  String uri = "http://maps.google.com/maps?saddr=" + src_lat+","+src_lon+"&daddr="+des_lat1+","+des_lon1;
   Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri));
   intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
   startActivity(intent);

Here is the code for drawing a route between two locations where both the source and destination's latitude and longitude are known. But here I want to replace my location's longitude and latitude to src_lon and src_lat, whose values I do not know and this longitude and latitude are changed with my current location. Is it possible to draw such a type of route?


Solution

  • Try this:

    Intent i = new Intent(android.content.Intent.ACTION_VIEW,
           Uri.parse("google.navigation:q=" +destLat+ ","+destLon+""));
    this.startActivity(i);
    

    This is the best the solution I know.