Search code examples
androidgoogle-mapsgoogle-maps-android-api-2driving-directionsgoogle-directions-api

Getting direction between coordinates without using Google direction web service


I know it is possible to get direction between coordinates using Google's direction web service. But is there any other way to get equally accurate route?

I found few questions on SO those use http://maps.google.com/ to get direction. But then also found few answers on other questions which state that it is no longer supported.

I am confused as this is the first time I am dealing with Google maps for android.

Is there any built in android sdk method to get direction?


Solution

  • you can send an intent to the google maps app and have the app do all the work for you but its not documented and probably never will be.

    to do that you can either give it a lattitue/longitude like this

    Intent NavIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("google.navigation:q=" +latitude +","+longitude));
    startActivity(NavIntent);
    

    or using the same intent but with an address and see if maps can resolve the address. (I dont have an example with an address).

    Other than using google directions API or other 3rd party direction web services there really is no other way to get directions in your app unless you look at Open Street Maps where you calculate the directions yourself using way points but that is quite involved