Android的导航意图意图、Android

2023-09-07 03:43:16 作者:紫衫龙王罩

如果您邮寄谷歌地图的方向你的Andr​​oid手机,你在地图appliaction打开它的可能性,这似乎完全合乎逻辑的,一样的code后面。

If you mail a Google Maps direction to your Android phone, you have the possibility to open it in the Maps appliaction, this seems perfectly logical, as does the code behind it.

现在,在地图应用程序一次,你要打开的导航应用这些方向,这些明确的方向的可能性。

Now, once in the Maps App, you have the possibility to open these directions in the Navigation App, with those exact directions.

这是如何工作的?它不能是很难做到这一点,我知道的意图

How does this work? It must not be that difficult to do it, I know about the intent with

"google.navigation:q=..."

不过,在某些设备上,只用坐标或地址,这只能......没有地图路线?

But this only works on some devices and only with coördinates or addresses... No Maps directions?

谁能帮我这个?

编辑:

这是URL看起来是这样的:

This is what the URL looks like:

https://maps.google.com/maps?saddr=Durbanville,+Cape+Town,+Western+Cape,+South+Africa&daddr=Parow+North,+Cape+Town,+South+Africa+to:Somerset+West,+Cape+Town,+South+Africa+to:Milnerton,+Cape+Town,+South+Africa&hl=en&ll=-33.955037,18.657532&spn=0.25032,0.528374&sll=-33.911454,18.601913&sspn=0.250448,0.528374&geo$c$c=FczB-_0dzIkcASlBKWkzGlfMHTFTuxOUSmpCAw%3BFQTi-v0d5oMbASld0qgMSFrMHTG2XqWY145Ttw%3BFfUG-P0dPHEfASk398T7ZbXNHTG5a6EH84n4Qg%3BFVU8-_0doEkaASnrz9UPVVnMHTFz2N4nnkA7XQ&oq=parow&mra=ls&t=m&z=12

推荐答案

如果您在格式创建一个Web网址

If you create a web url in the format

http://maps.google.com/maps?saddr=[lat 1],[lon 1]&daddr=[lat 2],[lon 2]

其中 [纬度1] 和 [LON 1] 是起点的经度和纬度,同样的 [纬度2] 和 [LON 2] 是终点,并将其设置为字符串,你就可以发送该给意图

where [lat 1] and [lon 1] are the latitude and longitude for the start point, and likewise [lat 2] and [lon 2] are the end point, and set it as a String, you can then send this to an intent:

Intent navIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(navigationUrl));
activity.startActivity(navIntent);

这将给用户打开的 Web浏览器的选项 谷歌地图或导航。

This will give the user the option of opening a Web Browser, Google Maps, or Navigation.

编辑:

有关多个目的地下面添加到URL的末尾(每增加地方)

For multiple destinations add the following to the end of the url (for each additional place)

+to:[lat 3],[lon 3]

根据需要。

因此​​,对于4目的地你会:

So for 4 destinations you would have:

http://maps.google.com/maps?saddr=[lat 1],[lon 1]&daddr=[lat 2],
  [lon 2]+to:[lat 3],[lon 3]+to:[lat 4],[lon 4]