Showing Route through Google Map in Android

To show the route between two places in google map, we can use

"http://maps.google.com/maps?&saddr=13.042206,80.17000&daddr=9.580000,78.100000"

this url.

Here I used the latitude and longitude of Chennai and Madurai, two cities in India.

The complete code snippet is,

 

public class LaunchMap extends MapActivity {

Uri uri;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
uri =Uri.parse("http://maps.google.com/maps?&saddr=13.042206,80.17000&daddr=9.580000,78.100000");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
finish();
}

@Override
protected boolean isRouteDisplayed() {
return false;
}
}



For showing this, we need to include the google map library in Manifest file.

A the time of launching , a pop up will ask to open in Browser or Google maps, just click on google map and it will show a list displaying the step by step direction as,



If we click on the list item it will show the map as,

Comments

Popular posts from this blog

AlarmManager and Notification in Android

Swipe Action and ViewFlipper in Android

Difference between SurfaceView and View in Android