I am trying to find map direction between two location. source location is device location. destination location is database which I maintain. Here is my code. I am able to reach the screen where I choose transit mode bus ,train,subway but I get result like No route found. I am able to see "My Location " in From field and latitude and longitude in to location Here is my code for get direction.
protected void getDirections() {
// TODO Auto-generated method stub
double dlongtd =result.get(0).getLongitude() ,dlattd=result.get(0).getLatitude();
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?f=d&daddr="+dlongtd+","+dlattd));
intent.setComponent(new ComponentName("com.google.android.apps.maps",
"com.google.android.maps.MapsActivity"));
startActivity(intent);
}
this the dialog box I get
and when I click any one of the transit I get no routs found toast
One Mistake which I did above is I was passing longitude instead of latitude and vice versa.Everything works fine now
updated code:
protected void getDirections() {
// TODO Auto-generated method stub
double dlongtd =result.get(0).getLongitude() ,dlattd=result.get(0).getLatitude();
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?f=d&daddr="+dlattd+","+dlongtd));
intent.setComponent(new ComponentName("com.google.android.apps.maps",
"com.google.android.maps.MapsActivity"));
startActivity(intent);
}