Thursday, July 1, 2010

Location Manager for compass movment n to call methods on changing angle from one quater to another.

class.h

@interface class : UIViewController
{
CLLocationManager *locationManager;
}

class.m


#pragma mark -
#pragma mark Geo Points methods

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
if(newLocation != nil)
currentLocation = newLocation;
else
currentLocation = oldLocation;

[self btn_POIStartClicked];
}

- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
{
/*NSString *msg=[NSString stringWithFormat:@"New magnetic heading: %f and New true heading: %f. ",newHeading.magneticHeading,newHeading.trueHeading];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Info" message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
alert = nil;
NSLog(@"New true heading: %f", newHeading.trueHeading);
NSLog(@"New magnetic heading: %f", newHeading.magneticHeading);*/
int angle = newHeading.magneticHeading;
CGAffineTransform rotate = CGAffineTransformMakeRotation( newHeading.magneticHeading/180*3.14 );
[compassView setTransform:rotate];

if(oldAngel != (angle/90))
{
switch (angle/90)
{
case 0:
{

}
break;
case 1:
{

}
break;
case 2:
{

}
break;
case 3:
{

}
break;
}
}
}

No comments:

Post a Comment