When i use setShowsUserLocation with MKMapView to track user location, how do I set the accuracy and distance filter? I am not talking about
For displaying map here is an example code.
First import MKMapKit and CoreLocation framework in your .h file.
#import
#import
Add MKMapKit and CoreLocation Delegate in .h file
@interface MapViewController : UIViewController
CGPoint gameMapCenter = CGPointMake([[UIScreen mainScreen] bounds].size.width / 2, [[UIScreen mainScreen] bounds].size.height / 2);
gameMapView = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, 640, 620)];
[gameMapView setCenter:gameMapCenter];
[gameMapView setMapType:MKMapTypeStandard];
[gameMapView setDelegate:self];
[self.view addSubview:gameMapView];
[gameMapView setShowsUserLocation:YES];
Use CLLocationManager for fetching user location.
Declare an instance of CLLocationManager
CLLocationManager *locationManager;
In ViewDidLoad
locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[locationManager setDistanceFilter:kCLDistanceFilterNone];
[locationManger startUpdatingLocation];
startUpdatingLocation Method Implementation:
(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
//Your Stuff
}