在 Android 1.0 上,有一个用于行车路线的 com.google.googlenav 命名空间:
路线 - 改进的 Google 行车路线
但在较新的 SDK 中,由于某种原因它被删除了......
Android:自 API 1.0 起删除了 DrivingDirections - 如何在 1.5/1.6 中执行此操作?
在 BlackBerry 上也缺乏此类功能的 API:
如何查找 Blackberry 中两个地点之间的路线?< /a>
csie-tw 给出了一个解决方法(查询 gmaps 中的 kml 文件并解析它):
Android - 行车方向(路线路径)
Andrea 还制作了一个DrivingDirections 帮助程序类。
我在 j2me 中为此功能编写了一个小助手,因此我想在 Android 和 BlackBerry 上分享我的示例。
更新
正如评论中所述,官方不允许这样做 Google Maps API 服务条款:
Google 地图/Google 地球 API 服务条款
最后更新时间:2009 年 5 月 27 日
...
10. 许可限制。除非本条款明确允许,或者除非您事先收到 Google(或特定内容提供商(如适用))的书面授权,否则 Google 的上述许可须遵守以下所有限制。除非第 7 节或地图 API 文档明确允许,否则您不得(也不得允许任何其他人):
...
10.9 将服务或内容与任何产品、系统或应用程序一起用于以下用途或与之相关:
(a) 实时导航或路线引导,包括但不限于与用户支持传感器的设备的位置同步的逐向路线引导;
并且可能会对某些应用程序禁用(至少在 Android 上)...来自 .NET 对话中的地理编码抓取:
API 使用条款不允许这样做。你不应该刮
Google 地图生成地理编码。我们将阻止这样做的服务
我们的服务器的自动查询。
布雷特·泰勒
Google 地图产品经理
如果您有任何替代方案和/或建议,我们将不胜感激!
谢谢!
On Android 1.0 there was a com.google.googlenav namespace for driving directions:
Route - Improved Google Driving Directions
But in newer SDK it was removed by some reason...
Android: DrivingDirections removed since API 1.0 - how to do it in 1.5/1.6?
On BlackBerry there is also lack of APIs for such stuff:
how to find the route between two places in Blackberry?
csie-tw gives a workaround (query gmaps for kml file and parse it):
Android - Driving Direction (Route Path)
Also Andrea made a DrivingDirections helper classes for Android.
I wrote a little helper for this functionality, in j2me, so I would like to share my samples on Android and BlackBerry.
UPDATE
As it was stated in comments, it's not officially allowed Google Maps APIs Terms of Service :
Google Maps/Google Earth APIs Terms of Service
Last updated: May 27, 2009
...
10. License Restrictions. Except as expressly permitted under the Terms, or unless you have received prior written authorization from Google (or, as applicable, from the provider of particular Content), Google's licenses above are subject to your adherence to all of the restrictions below. Except as explicitly permitted in Section 7 or the Maps APIs Documentation, you must not (nor may you permit anyone else to):
...
10.9 use the Service or Content with any products, systems, or applications for or in connection with:
(a) real time navigation or route guidance, including but not limited to turn-by-turn route guidance that is synchronized to the position of a user's sensor-enabled device;
and may be disabled for certain apps (somehow, at least on Android)... From Geocode scraping in .NET conversation:
This is not allowed by the API terms of use. You should not scrape
Google Maps to generate geocodes. We will block services that do
automated queries of our servers.
Bret Taylor
Product Manager, Google Maps
Would be grateful for any alternatives and/or suggestions!
Thanks!
发布评论
评论(1)
J2ME 地图路线提供商
maps.google.com 提供导航服务,可以为您提供 KML 格式。
要获取 kml 文件,我们需要形成包含起始位置和目标位置的 url:
接下来,您需要解析 xml(使用 SAXParser 实现)并填充数据结构:
网络连接在 Android 和 Blackberry 上以不同的方式实现,因此您必须首先form url:
然后与此url创建连接并获取InputStream。
然后传递此InputStream并获取解析的数据结构:
完整源代码RoadProvider.java
BlackBerry
在 J2MEMapRouteBlackBerryEx on Google Code
Android
查看完整代码Google 代码上的 J2MEMapRouteAndroidEx
J2ME Map Route Provider
maps.google.com has a navigation service which can provide you route information in KML format.
To get kml file we need to form url with start and destination locations:
Next you will need to parse xml (implemented with SAXParser) and fill data structures:
Network connection is implemented in different ways on Android and Blackberry, so you will have to first form url:
then create connection with this url and get InputStream.
Then pass this InputStream and get parsed data structure:
Full source code RoadProvider.java
BlackBerry
See full code on J2MEMapRouteBlackBerryEx on Google Code
Android
See full code on J2MEMapRouteAndroidEx on Google Code