如何将坐标列表传递给默认的Google地图应用程序?

编程入门 行业动态 更新时间:2024-10-26 11:22:48
本文介绍了如何将坐标列表传递给默认的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);

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

字符串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);

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

您可以查看下面的链接,以指定源和目标之间的航点:$ b​​ $ b developers.google/maps/documentation/urls/android-intents

如果您有任何疑问,请告知我。

From my app i am opening the default google map app. Here is how i am doing it.

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);

This is working fine. But is it possible to pass a list of coordinates and plot them all so i could create a path?

解决方案

Here try this:

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);

this will open map in navigation mode from your current location to the specified destination.

you can have a look at the below link to specify way points between your source and destination: developers.google/maps/documentation/urls/android-intents developers.google/maps/documentation/urls/guide

Let me know if you have any doubts.

更多推荐

如何将坐标列表传递给默认的Google地图应用程序?

本文发布于:2023-11-16 07:45:43,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:坐标   如何将   应用程序   地图   列表

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!