问题描述
关于 Android 和 Google 路线服务的一些问题:
Some questions about Android and Google Directions Service:
Android 上是否有使用 Google 提供的路线服务的本机方式,或者是否有任何不错的 Wrapper 框架?我想检索从 A 到 B 所需的时间,并可能在表格和/或地图中显示路线.
Is there a native way on Android to use the Directions Service from Google or are there any nice Wrapper Frameworks?I would like to retrieve the time needed to get from A to B and maybe show the route in a table and/or map.
据我所知,只能检索步行"和驾驶"的方向.有没有办法(可能不是来自谷歌)也为公共交通工具或骑自行车"获取这些信息?
As far as I know directions can only be retrieved for "walking" and "driving". Is there a way (maybe not from google) to get this Information also for public transports or "biking" ?
推荐答案
我不知道这是否正是您想要的,但您可以激发这样的意图:
I don't know exactly if this is what you want, but you could fire up an intent like this:
String url = "http://maps.google.com/maps?saddr=some+address&daddr=another+Address"
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(url));
要获取骑车路线,请在网址中添加&dirflg=b".对于公共交通,添加dirflg=r".
To get biking directions add "&dirflg=b" to the url. For public transport add "dirflg=r".
这将在谷歌地图应用中显示路线.如果您想在地图视图中的应用程序中获取此内容,请参阅 github 上的此代码.您可以修改代码以添加骑自行车和公共交通功能.
This will display the route in the google Maps app. If you want to get this in your app inside a mapview, please see this code at github. You could hack into the code to add biking and public transport functionality.
希望这会有所帮助.
这篇关于Android 谷歌路线服务可以原生使用吗?使用包装框架?公共交通/自行车路线可用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!