开发者

launch the Google navigation to a specific location by providing GPS coordinates

开发者 https://www.devze.com 2023-03-16 16:08 出处:网络
I want know if it\'s possible to launch the Google n开发者_运维问答avigation to a specific location by providing GPS coordinates of that location from an application.If you mean you want to launch goo

I want know if it's possible to launch the Google n开发者_运维问答avigation to a specific location by providing GPS coordinates of that location from an application.


If you mean you want to launch google turn by turn navigation from your application by providing latitude & longitude coordinates, then here is the code:

public void launchNavigation(){
    String location = mLat + "," + mLng;
    Uri gmmIntentUri = Uri.parse("google.navigation:q="+location);
    Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
    mapIntent.setPackage("com.google.android.apps.maps");
    startActivity(mapIntent);
}

Basically in the Uri parameter you can pass either street address or Lat,Lng like the following:

google.navigation:q=a+street+address
google.navigation:q=latitude,longitude

I hope this could help someone with the same problem as I guess your problem would have been resolved long ago.

0

精彩评论

暂无评论...
验证码 换一张
取 消