Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top