Launching Google Maps Directions via an intent on Android

后端 未结 15 1566
小鲜肉
小鲜肉 2020-11-22 03:46

My app needs to show Google Maps directions from A to B, but I don\'t want to put the Google Maps into my application - instead, I want to launch it using an Intent. Is this

15条回答
  •  北荒
    北荒 (楼主)
    2020-11-22 04:31

    If you interested in showing the Latitude and Longitude from the current direction , you can use this :

    Directions are always given from the users current location.

    The following query will help you perform that . You can pass the destination latitude and longitude here:

    google.navigation:q=latitude,longitude
    

    Use above as:

    Uri gmmIntentUri = Uri.parse("google.navigation:q=latitude,longitude");
    Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
    mapIntent.setPackage("com.google.android.apps.maps");
    startActivity(mapIntent);
    

    Or if you want to show via location , use:

    google.navigation:q=a+street+address
    

    More Info here: Google Maps Intents for Android

提交回复
热议问题