是否有一个Android相当于谷歌地图URL方案的iOS? [英] Is there an Android equivalent to Google Maps URL scheme for iOS?

查看:164
本文介绍了是否有一个Android相当于谷歌地图URL方案的iOS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想打开谷歌地图在导航模式下,从一个移动网页链接。这似乎很容易为iOS设备上使用<一个href="https://developers.google.com/maps/documentation/ios/urlscheme">https://developers.google.com/maps/documentation/ios/urlscheme

I want to open Google Maps in Navigation mode from a mobile web link. This seems easy enough for iOS devices using https://developers.google.com/maps/documentation/ios/urlscheme

有一种等效为Android?所有我能找到的是这样的:<一href="https://developer.android.com/guide/appendix/g-app-intents.html">https://developer.android.com/guide/appendix/g-app-intents.html

Is there an equivalent for Android? All I could find was this: https://developer.android.com/guide/appendix/g-app-intents.html

但是,这并不让你指定transitmode,需要获得方向,据我可以告诉其他参数。

But that doesn't allow you to specify "transitmode" and the other parameters needed to get directions as far as I can tell.

推荐答案

其实,有轻微的iOS的文档说明会在这里工作过的方法修改(我测试了它把它在这里尽管之前,在本机应用程序,而不是网络链接)。

Actually, a slight modification of the methods described in the iOS Doc would work here too (I tested it before putting it here albeit, in a native app and not a web link).

需要这个工作的参数pretty的大致相同的iOS的文件中列出的:

The parameters necessary for this to work are pretty much the same as with the ones listed in the iOS documentation:

从IOS文档:

参数:

  • SADDR :设置起点方向搜索。这可以是一个 纬度,经度或查询格式的地址。如果它是一个查询 字符串,返回多个结果,第一结果将是 选中。如果值留空,则该用户的当前 位置将被使用。
  • DADDR :设置方向搜索的终点。具有相同 格式和行为作为SADDR。
  • directionsmode :运输方式。可以设置为: 驾驶,交通,或步行。
  • saddr: Sets the starting point for directions searches. This can be a latitude,longitude or a query formatted address. If it is a query string that returns more than one result, the first result will be selected. If the value is left blank, then the user’s current location will be used.
  • daddr: Sets the end point for directions searches. Has the same format and behavior as saddr.
  • directionsmode: Method of transportation. Can be set to: driving, transit, or walking.

他们实际上,pretty的大致相同。然而,它们没有在那里将在文档中找到。此外,虽然前2个参数,在这里工作的常用方法,最后一个参数的 directionsmode 不工作,是。一种解决方法是但是,下面列出。

They are actually, pretty much the same. They are however, no where to be found in the documents. Also, while the first 2 parameters work the usual way here, the last parameter directionsmode does not work as is. A workaround is however, listed below.

话虽这么说,一个简单的URL可以,然后可以通过为乌里来的构造意图这将随后处理被启动的应用程序(如果已安装并/或浏览器列表谷歌地图可供选择)

That being said, a simple URL can be constructed that can then be passed as an Uri to an Intent that will then handle the application to be launched (Google Maps if installed and/or list of browsers to choose from)

String mapURL = http://maps.google.com/maps?saddr=-33.9417, 150.9473&daddr=-33.92050, 151.04287&dirflg=d
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(mapURL));
startActivity(intent);

一些变化了的交通模式的:

  1. &放大器; dirflg = D =为驾驶方向(这是默认模式,而不出来是一样的把它在explicityly。 )。
  2. &放大器; dirflg = W 的=步行路线
  3. &放大器; dirflg = R 的=公共交通
  4. &放大器; dirflg = B 的=的骑车路线
  1. &dirflg=d = for Driving directions (this is the default mode. leaving it out is the same as putting it in explicityly).
  2. &dirflg=w = for Walking directions
  3. &dirflg=r = for Public transit.
  4. &dirflg=b = for Biking directions.

这就是说,在运行这些测试的时间(我承认我很好奇,看到了这个问题的;-)之后测试远一点),在的the出行方式部分 不要似乎工作!

That being said, at the time of running these test (I admit I was curious enough to test a little further after seeing this question ;-) ), the modes listed in the Travel Modes section don't seem work!

各种各样的小证明:

注:抵免的选项最初发现

这篇关于是否有一个Android相当于谷歌地图URL方案的iOS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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