snksnk
snksnk

Reputation: 1595

Display speed on mkmap - Xcode

When running this log:

-(void) locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{

NSLog(@" new -> %@ \n old -> %@",(newLocation),(oldLocation));

i get:

new -> <+37.33328787,-122.05209673> +/- 5.00m (speed 33.57 mps / course 254.88) @ 9/30/12, 9:53:15 AM Eastern European Summer Time

old -> <+37.33336511,-122.05174034> +/- 5.00m (speed 33.73 mps / course 255.23) @ 9/30/12, 9:53:14 AM Eastern European Summer Time

How can I display, in real time, speed shown by "mps" (meters per second) on a UILabel?

Thank you in advance..

Upvotes: 0

Views: 1156

Answers (1)

Carl Veazey
Carl Veazey

Reputation: 18363

CLLocation has a property speed. Assuming you want to display location's speed in label, do something like:

NSString *speedString = [NSString stringWithFormat:@"Speed is %.2f meters per second.",location.speed];
label.text = speedString;

You can find out about more properties of CLLocation or any class by searching the documents in Xcode with cmd-option-shift-?, or my searching the internet for "CLLocation class reference". You can quickly scan the outline at the top of these documents for things that might answer your question. Oftentimes, methods and properties related to similar tasks are grouped together. This makes it easy to quickly find out if a class can meet your needs.

Hope this helps!

Upvotes: 3

Related Questions