通过Android Intent在Google地图中添加多个路点 [英] Adding multiple way points in Google Maps via Android Intent

查看:166
本文介绍了通过Android Intent在Google地图中添加多个路点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为我应用中导航的一部分,我正在将我的应用重新定向到Google Maps以及lats和long。我已经成功地传递了来源和目的地,并直接在Google地图中打开它。

  Uri gmmIntentUri = Uri.parse(google.navigation:q = 9.883456,78.120150); 
Intent mapIntent = new Intent(Intent.ACTION_VIEW,gmmIntentUri);
mapIntent.setPackage(com.google.android.apps.maps);
startActivity(mapIntent);

但是我的问题 / strong>通过意向传送给Google地图。最近Google推出了在移动版Google地图应用中添加多个目的地,并且我认为它可以在Google Directions API中使用,但我不想通过在我的应用中集成Google Directions来扭曲路径,我宁愿选择通往谷歌地图的高速公路。



我一直在寻找这个主题,但我发现的是以下内容,但这也不起作用。

  Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse(http://maps.google.com/maps?saddr=st。 %20louis,MO&安培; DADDR =华盛顿特区%20to:芝加哥,伊利诺伊%20to:新%20york,NY));
startActivity(intent);

以上代码仅在我们在Chrome中打开它时才起作用,但我希望它在Google地图中打开并且甚至添加一个 mapIntent.setPackage(com.google.android.apps.maps); 不起作用,但它很显然,上面的uri传递的是一个URL在网络版Google地图中可用。



任何有关如何实现这一目标的见解或任何想法都会受到欢迎。



PS:完全可以实现这个目标吗?

解决方案


  1. 构造URL = https://www.google.co.in/maps/dir/18.6121132,73.707989/18.642344,73.707880/18.652344,73.727880/18.6530132,73.7270 < a>

    以上网址

    source = 18.6121132,73.707989

    waypoint1 = 18.642344,73.707880

    waypoint2 = 18.652344,73.727880

    目的地= 18.6530132,73.7270

  2. ( https://www.google.co.in/maps/dir/18.6121132,73.707989/18.5,73.7/18.8,73.71);
    Intent mapIntent = new Intent(Intent.ACTION_VIEW,gmmIntentUri);
    mapIntent.setPackage(com.google.android.apps.maps);
    startActivity(mapIntent);


我用多种方式测试过点和它为我工作。
我希望这可以帮助其他人



注意:它仅适用于最新Android谷歌地图应用程序


As a part of navigation in my app, I am re-directing my app to Google Maps along with the lats and longs. I have already succeeded in passing the source and destination and making it open in Google Maps directly.

Uri gmmIntentUri = Uri.parse("google.navigation:q=9.883456,78.120150");
Intent mapIntent = new Intent(Intent.ACTION_VIEW,gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);

But my question is how do I pass multiple points to Google Maps via intent. Recently Google introduced adding multiple destinations in the mobile version of the Google Map app and I presume that its available in the Google Directions API but I don't want to take the twisted path by integrating Google Directions in my app, I'd rather take the highway to Google Maps.

I have been searching a lot on this topic but all I find is the following but that doesnt work either.

Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?saddr=st.%20louis,mo&daddr=washington,dc%20to:chicago,il%20to:new%20york,ny"));
startActivity(intent);

The above code works only when we open it in Chrome but I want it to open in Google Maps and even adding a mapIntent.setPackage("com.google.android.apps.maps"); doesn't work but its kinda obvious that the above uri passed is a URL that's available in Google Maps of web version.

Any insights or any ideas on how this can be achieved will be more than welcomed.

P.S: Can this be achieved at all ?????

解决方案

  1. Contruct URL = https://www.google.co.in/maps/dir/18.6121132,73.707989/18.642344,73.707880/18.652344,73.727880/18.6530132,73.7270

    In above URL

    source = 18.6121132,73.707989

    waypoint1 = 18.642344,73.707880

    waypoint2 = 18.652344,73.727880

    destination = 18.6530132,73.7270

  2. Call Google Map Intent URI

    Uri gmmIntentUri = Uri.parse("https://www.google.co.in/maps/dir/18.6121132,73.707989/18.5,73.7/18.8,73.71"); Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri); mapIntent.setPackage("com.google.android.apps.maps"); startActivity(mapIntent);

I have tested it with multiple way points and it worked for me. I hope this will help others

Note: It works only on latest Android Google Maps application

这篇关于通过Android Intent在Google地图中添加多个路点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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