如何将坐标列表传递给默认的Google地图应用程序? [英] How to pass a list of coordinates to the default google Map Application?

查看:206
本文介绍了如何将坐标列表传递给默认的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 https://developers.google.com/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: https://developers.google.com/maps/documentation/urls/android-intents https://developers.google.com/maps/documentation/urls/guide

Let me know if you have any doubts.

这篇关于如何将坐标列表传递给默认的Google地图应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆