谷歌地图按纬度和经度导航无法在某些手机中使用

时间:2015-03-14 08:37:09

标签: android google-maps

我使用下面的代码在按钮click.myLatitude和&上打开谷歌地图。 myLongitude都是双倍值。在我的手机中,它可以工作,并说导航到一些xx.xxx xx.xxxx 但是在某些手机中,它表示xx.xxx xx.xxx()并且没有显示任何结果。为什么?

 public void onClick(View view) {


                    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:<" + myLatitude  + ">,<" + myLongitude + ">?q=<" + myLatitude  + ">,<" + myLongitude + ">("  + ")"));
                    startActivity(intent); 

                }

1 个答案:

答案 0 :(得分:0)

我认为你应该使用Google Maps Android API v2,用于导航的URI编码查询字符串如下所示:google.navigation:q=latitude,longitude

话虽如此,您的代码应该看起来像这样:

    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("google.navigation:q="+myLatitude+","+myLongitude));
    startActivity(intent);

我在Android 2.3,4.4和5.0上测试过,它运行正常。

有关Google Maps Android API v2的更多信息,您可以查看此网站: https://developers.google.com/maps/documentation/android/intents#launch_turn-by-turn_navigation