Android - 两个城市之间的距离

发布于 2024-09-13 04:04:45 字数 109 浏览 4 评论 0原文

我的 Android 应用程序需要两个城市之间的距离和驾驶时间。

是否有可能通过 Google Navigator 或 Google Maps 来计算这些东西? (行驶距离,不是航空距离)

I need in my Android Application the Distance and the Driving Time between Two cities.

Is there a possibility to calculate this things for example via Google Navigator or Google Maps? (the driving distance, not the air-line distance)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

倦话 2024-09-20 04:04:45

您应该使用 提供的 Java 包装器,而不是如上所述直接使用 Web api http://code.google.com/p/gdata-java-client/ 此处有有关地图 API 的详细信息
http://code.google.com/apis/maps/documentation/ mapsdata/developers_guide_java.html

请记住,这不是 android 地图 jar api,而是其他 api 内容,因此您需要在 apk 构建中包含该 jar。

Instead of using the web api directly as mentioned above you should use the Java wrappers as provided by http://code.google.com/p/gdata-java-client/ with more information about the maps api in detail here
http://code.google.com/apis/maps/documentation/mapsdata/developers_guide_java.html

Keep in mind that this is NOT the android maps jar api but additional api stuff so you will need to include the jar in your apk build.

伪装你 2024-09-20 04:04:45

是的,这是可能的,但您需要使用 Google Maps Web API,因为 Android SDK 没有任何路线计算功能(自 v0.9 起不再提供)。

您可以在这里找到一些路线计算的示例(请参阅我的回复:如何使用 kml 文件在地图上绘制路径?

您要做的就是创建一个 Google 地图请求 URL,其中包括所有必要的参数,如地理点和模式(行人、驾驶)然后以 KML (xml) 数据的形式获取响应(您只需将 &output=kml 添加到 Google URL),其中包含您需要的所有信息(时间和距离)。然后,您需要使用 ie sax 解析器解析响应(kml/xml),如我的示例代码中所示。

另请参阅此帖子:
如何通过 HTTP 服务器端请求获取 Google 地图公共交通路线

Yes, it's possible, but you need to use the Google Maps Web API, since the Android SDK doesn't have any route calculation features (anymore, since v0.9).

You can find some sample for route calculation here (see my reply: How to draw a path on a map using kml file?)

What you do is you create a Google maps request URL including all necessary parameters like geo points and mode (pedestrian, driving) and then fetch the response as KML (xml) data (you just add &output=kml to the Google URL), which holds all the information you need (time and distance). You need to parse the response (kml/xml) then, with i.e. a sax parser, as in my sample code.

Also see this post:
How to get Google Maps Public Transit Directions by HTTP server-side request

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文