// // ViewController.m // MapView // // Created by UEC on 6/1/16. // Copyright (c) 2016年 uec. All rights reserved. // #import "ViewController.h" @interface ViewController () @end @implementation ViewController @synthesize latLabel, longLabel, arrowImage; - (void)viewDidLoad { [super viewDidLoad]; lm = [[CLLocationManager alloc]init]; lm.delegate = self; lm.desiredAccuracy = kCLLocationAccuracyHundredMeters; lm.distanceFilter = kCLHeadingFilterNone; [lm startUpdatingHeading]; [lm startUpdatingLocation]; // Do any additional setup after loading the view, typically from a nib. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } -(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { // Every 5s or Every 10m, this method will be called latLabel.text = [NSString stringWithFormat:@"%f",newLocation.coordinate.latitude]; longLabel.text = [NSString stringWithFormat:@"%f",newLocation.coordinate.longitude]; } -(void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading { // Need to convert the degree to radian arrowImage.transform = CGAffineTransformMakeRotation(newHeading.magneticHeading * M_PI / 180); } @end