Walking, bicycle and public transport directions with time required in each mode , iPhone
Asked Answered
Q

1

4

I am using following url to get driving directions between two locations.

 NSString* apiUrlStr = [NSString stringWithFormat:@"http://maps.google.com/maps?output=dragdir&saddr=%@&daddr=%@", saddr, daddr];

What changes need to be done in above query to get directions for bicycle, walking or public transport and corresponding distance, time required between two places?

Thanks in advance for any help.

Quipster answered 3/10, 2011 at 8:51 Comment(0)
Q
7

You must use the "dirflg=?" parameter, where "?" can be:

dirflg Route type.
dirflg=h Switches on "Avoid Highways" route finding mode.
dirflg=t Switches on "Avoid Tolls" route finding mode.
dirflg=r Switches on "Public Transit" - only works in some areas. Can also set date and time info described below.
dirflg=w Switches to walking directions - still in beta.
dirflg=b Switches to biking directions - only works in some areas and still in beta.

There are many other params available, read the Google Maps Parameters doc, but of course not all of them are supported by the Maps native API (which is updated at every iOS release). Is up to you to test them as the official Apple doc is not always up to date with all features.

Quaternary answered 3/10, 2011 at 9:10 Comment(3)
Thanks a lot viggio24....!!! it worked exactly as required. I have quickly gone through doc you suggested and Could not find parameters associated with time required for each mode of transport (I assume google takes traffic into account). Can this information be retrieved from using above URL with appropriate parameters or I need to use different method?Quipster
when you open the Maps.app with the dirflg parameters the application automatically display the map, the distance and the estimated time. If you want to retrieve this information without using the Maps.app then you must go to the more complex maps API using google web services: code.google.com/apis/mapsQuaternary
In 2018 "dirflg=x" means request a ride (taxi).Cathepsin

© 2022 - 2024 — McMap. All rights reserved.