2017-07-06 80 views
0

从我的应用程序,我打开默认的谷歌地图应用程序。这是我如何做到的。如何将坐标列表传递给默认的Google地图应用程序?

String uri = String.format(Locale.ENGLISH, "geo:0,0?q=%f,%f(%s)", 
       locationList.get(1).getLatitude(), locationList.get(1).getLongitude(),"My location"); 
     Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); 
     Log.i(TAG, "Uri is "+ uri); 
     this.startActivity(intent); 

这工作正常。但是有可能传递一个坐标列表并将它们全部绘制出来,以便我可以创建一条路径?

+0

你想绘制从一个目的地到谷歌地图上的其他路径? – sumit

+0

我想绘制存储在列表中的多个坐标之间的路径。 – KingintheNorth

回答

0

这里试试这个:

String destination = locationList.get(1).getLatitude()+"," 
        +locationList.get(1).getLongitude(); 
      Uri gmmIntentUri = Uri.parse("google.navigation:q="+destination+"&mode=d"); 
      Log.e(TAG,"Intent uri : "+gmmIntentUri.toString()); 
      Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri); 
      mapIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
      mapIntent.setPackage("com.google.android.apps.maps"); 
      this.startActivity(mapIntent); 

这将在导航模式下打开地图从当前位置到指定的目标。

,你可以看看下面的链接到你的源和目标之间的指定方式分: https://developers.google.com/maps/documentation/urls/android-intents https://developers.google.com/maps/documentation/urls/guide

让我知道如果您有任何疑问。

+0

虽然可以发送多个坐标吗?我在这里询问了这个问题:https://stackoverflow.com/q/47690024/878126 –

相关问题