Google Maps HTTP API用于驾车和步行路线 [英] Google Maps HTTP API for driving and walking directions

查看:186
本文介绍了Google Maps HTTP API用于驾车和步行路线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你知道如何通过给出两个特定的坐标来从Google获得步行路线吗?
如何发送简单的HTTP GET请求并将结果存入KML文件?

我不想进行地理编码,但可以获取行车路线该方法返回的KML文件:

http://www.gringod.com/2008/02/26/save-google-maps-driving-directions/


目前还没有文档和批准的方法可通过HTTP请求访问Google Maps Directions API(更新:Google已添加2010年5月,通过网络服务路线指引) p>

尽管如此,返回JSON输出的未公开方法如下:

  http://maps.google.com/maps/nav?q=from:London%20to:Dover 

的格式 q 参数应该为:来自:xxx%20to:yyy 。将xxx和yyy分别替换为start和destination。您可以使用纬度和经度,而不是完整的地址。



默认情况下,此请求会返回行车路线。要获取步行路线,您可以将可选参数 dirflg = w 添加到查询字符串中。 (来源



<请注意,这不仅仅是没有记录的,但它也可能违反了 Google地图API条款



您可能会在查看以下文章时感兴趣:


Do you know how I can get walking directions from Google by giving two specific coordinates? How can I send simple HTTP GET requests and have the result in a KML file?

I don't want to geocode, but get the driving directions as the KML file returned by this method:

http://www.gringod.com/2008/02/26/save-google-maps-driving-directions/

解决方案

There is no documented and approved method at the moment to access the Google Maps Directions API via an HTTP request (update: Google added walking and driving directions via web services in May, 2010).

Nevertheless, an undocumented method that returns a JSON output is the following:

http://maps.google.com/maps/nav?q=from:London%20to:Dover

The format of the q parameter should be from:xxx%20to:yyy. Replace xxx and yyy with the start and destination respectively. You can use a latitude and a longitude instead of full addresses.

By default this request returns driving directions. To get walking directions you can add the optional parameter dirflg=w to the query-string. (Source)

Note that not only this is undocumented, but it may also violate the restrictions 10.1 and 10.5 of the Google Maps API Terms and Conditions.

You may also be interesting in checking out the following articles:

这篇关于Google Maps HTTP API用于驾车和步行路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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