Google Maps offers an API for querying directions. For example, a bicycle ride from Staffanstorp to Lomma, both in Skåne, Sweden is queried like this:
http://maps.googleapis.com/maps/api/directions/json?origin=Storgatan+4%2C+Staffanstorp%2C+Sweden&destination=Centrumgatan+13%2C+Lomma%2C+Sweden&mode=bicycling
The resulting file contains some useful information:
The total travel time is associated with the "duration" tag. The directions are listed under the "steps" tag.
A Google Maps set of bicycle directions between Staffanstorp and Lomma. |
The duration is found by browsing through the JSON tree to the tag that I need.
In my particular case, I compare the bicycle time with the public transit time at three different occasions. The shortest time is returned.
No comments:
Post a Comment