In my iPhone application I allow the user to choose a destination on the map, then when he starts driving toward the destination I want to give him information like: how long until he reaches the destination and what its current distance from the destination. I'm using CloudMade maps SDK for iPhone and i know there is an API method to get a path between two point that returns also the time and distance between them. Is it OK to call this method every time i get a new location from the CLLocationManager to get the updated time and distance? I assume this method query the CloudMade servers so i don't know if calling it a lot of time is the best way to do this..
Asked
Active
Viewed 844 times
2 Answers
0
Swift version would be:
var startLocation:CLLocation!
var lastLocation: CLLocation!
let distance = startLocation.distanceFromLocation(lastLocation)

Manish Verma
- 539
- 1
- 4
- 11
0
For distance
/*
* distanceFromLocation:
*
* Discussion:
* Returns the lateral distance between two locations.
*/
- (CLLocationDistance)distanceFromLocation:(const CLLocation *)location __OSX_AVAILABLE_STARTING(__MAC_10_6,__IPHONE_3_2);
For getting the time needed, you could calculate it yourself. CLLocation has a speed parameter. Use the distance and the speed to calculate time.

Yorxxx
- 679
- 3
- 4
-
i need the driving path distance and time, the method you suggested gives the absolute distance. – Eyal Sep 26 '11 at 08:38