Is it possible to get Google Maps Directions using HTTP requests?
Is it possible to use the Google Maps API router just using HTTP? Something like http://maps.google.com?from=blah?to=blah
And have it return some sort of XML or JSON 开发者_Python百科representing the directions?
If you want Google to allow legal access to driving directions via HTTP you might consider voting for the enhancement request: Issue 235. Theoretically, the more people that vote for an enhancement request, the more attention Google give to it.
However, I strongly suspect that there might be contractual issues with the organisations that supply the data. Organisations like TeleAtlas impose restrictions about how Google can use their data. TeleAtlas probably don't want Google to make it legal for people to use their data to create apps for free that directly compete with their own commercial apps and devices.
There is no documented and approved method to access driving directions via an HTTP API request.
This makes it difficult to get driving directions on the server-side, which I assume is your intention.
Not only it is undocumented and difficult to achieve, but it would also violate the restrictions 10.1 and 10.5 of the Google Maps API Terms and Conditions.
However, if you don't mind the challenge, and you believe that rules are there to be broken, you may want to check these articles:
- Calculate driving directions using PHP?
- Retrieve driving directions from google maps with server-side HTTP calls and show results with static maps for WAP
Actually yes, and they do it themselves
The REST format is like:
http://maps.google.com/maps/nav?output=js&q=from:%20Montreal%20to:%20Toronto&key=apikey
Where q
should have the form: "from: x to: y" (url encoded).
Some of the parameters are similar to the HTTP Geocoding service: http://code.google.com/apis/maps/documentation/geocoding/index.html
Mike
As of May, 2010, directions are available via web services:
http://code.google.com/apis/maps/documentation/directions/
Directions are returned in XML or JSON format:
http://maps.google.com/maps/api/directions/json?origin=Boston,MA&destination=Concord,MA&waypoints=Charlestown,MA|Lexington,MA&sensor=false http://maps.google.com/maps/api/directions/xml?origin=Boston,MA&destination=Concord,MA&waypoints=Charlestown,MA|Lexington,MA&sensor=false
It's pretty danged easy to use.
Here you can find a list of parameters you can pass to the maps.google.com URL. Maybe you'll be able to get the information you need. I don't know what the returned output contains. At least you are able to define different output types.
I have already used this library with python and it works well, although it's against Google Maps API Terms.
API v3 (made the official version in the last six months), does:
http://code.google.com/apis/maps/documentation/directions/
Also note that most of the competing services (Bing Maps, Yahoo, MapQuest, CloudMade, etc) also support RESTful web services along these lines.
As always with these services, check the Terms & Conditions.
I've never used the API but it is pretty easy to get the structured directions data from a google maps page using JS to access the gmap page's DOM.
精彩评论