Hello all,
I'm new here to this forum, and I have a question about getting the user location.
Current I have an App that will start and get the user location, but the problem that I have is that if I move the map around it the map always moves back to the current location, so I can never see around my location.
Here is the code I have on my app so far.
Code:
@synthesize locationManager, location;
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
mapView = [[MKMapView alloc] initWithFrame:self.view.bounds];
mapView.showsUserLocation = YES;
mapView.delegate = self;
mapView.scrollEnabled = YES;
mapView.zoomEnabled = YES;
mapView.userInteractionEnabled = YES;
[self.view insertSubview:mapView atIndex:0];
self.locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
location=newLocation.coordinate;
//One location is obtained.. just zoom to that location
MKCoordinateRegion region;
region.center=location;
//Set Zoom level using Span
MKCoordinateSpan span;
span.latitudeDelta=.005;
span.longitudeDelta=.005;
region.span=span;
[mapView setRegion:region animated:TRUE];
}