Hi,
I'm trying to do application that launches google maps. I'm using MKMapView and CLLocationManager to receive events.
My objective is to display the initial map in a smaller region. Now I'm displaying all the continents in the world
but I want to display just a small region in radius 10 meters to the user location.
So my code is running, no errors, but I obtain an initial map with all the continents. All I want is displaying smaller region within a certain radius.
Here is my code and thank you for the help:
I'm trying to do application that launches google maps. I'm using MKMapView and CLLocationManager to receive events.
My objective is to display the initial map in a smaller region. Now I'm displaying all the continents in the world
So my code is running, no errors, but I obtain an initial map with all the continents. All I want is displaying smaller region within a certain radius.
Here is my code and thank you for the help:
Code:
- (void)viewDidLoad {
[super viewDidLoad];
map = [[MKMapView alloc]initWithFrame:self.view.bounds];
map.delegate = self;
[self.view insertSubview:map atIndex:0];
CLLocationManager *locationManager = [[CLLocationManager alloc]init];
locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;//setting the desired accuracy
locationManager.distanceFilter = 100.0f;
locationManager.delegate = self; // Set the delegate to handle the messages from the location manager
//verifying if gps supported
if (locationManager.headingAvailable) {
[locationManager startUpdatingLocation];
}
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{
MKCoordinateRegion coordinateRegion;
coordinateRegion.center = newLocation.coordinate;
coordinateRegion.span.latitudeDelta = 0.005; //set zoom level
coordinateRegion.span.longitudeDelta = 0.005;
[map setRegion:region animated:TRUE];
}