Vikas Ojha Vikas Ojha - 2 years ago 98
iOS Question

calculate time taken to cover a journey in Apple Maps

I am working on MKMapView to get the direction between 2 locations.Is there any way i can get the time it may take in completing this journey?Is there any inbuilt property of

MKRoute or MKDirection
Class that can provide me time to cover this journey ?

Any help would be appreciated.


Answer Source


The MKDirections method named calculateETAWithCompletionHandler: can just be a bit easy to overlook, though.

An implementation could look as follows:

MKDirections *yourDirections = ...;

[yourDirections calculateETAWithCompletionHandler:^(MKETAResponse *response, NSError *error)
     NSTimeInterval estimatedTravelTimeInSeconds = response.expectedTravelTime;


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download