-
Notifications
You must be signed in to change notification settings - Fork 2
Directions
aferre edited this page Oct 1, 2011
·
3 revisions
cf [Google Directions API page] (http://code.google.com/intl/fr-FR/apis/maps/documentation/directions/) for the behaviour of the WS.
Here is an example:
afGoogleMapsDirectionsRequest *req = [af GoogleMapsDirestionsRequest directionsRequest];
req.afDelegate = self;
[req setUseSensor:YES];
[req setUseHTTPS:NO];
[req setAvoidMode:AvoidModeTolls]; //optional, none default
[req setUnitsSystem:UnitsMetric]; //optional, metrics default
[req setTravelMode:TravelModeBicycling]; //optional, driving default
[req setOrigin:@"Paris"];
[req setDestination:@"Boulogne billancourt"];
[req setAlternatives:YES]; //optional, NO default
[req startAsynchronous];
You need to make your controller implement the delegate methods:
-(void) afDirectionsWSStarted:(afGMapsDirectionsRequest *)ws ;
-(void) afDirectionsWS:(afGMapsDirectionsRequest *)ws gotRoutes:(NSArray *)routes;
-(void) afDirectionsWSFailed:(afGMapsDirectionsRequest *)ws withError:(NSError *)er;
They are all optional, meaning that it won't matter if you don't implement them, but you'll need them for obvious reasons. Actually, you could make a synchronous request and then retrieve the values you need on the request itself.