I cannot get my current location in iphone simulator. I set custom location to latitude and longitude to Egypt but doesn’t get current location.
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//Make this controller the delegate for the map view.
self.MapView.delegate = self;
// Ensure that you can view your own location in the map view.
[self.MapView setShowsUserLocation:YES];
//Instantiate a location object.
locationManager = [[CLLocationManager alloc] init];
[locationManager startUpdatingLocation];
//Make this controller the delegate for the location manager.
[locationManager setDelegate:self];
//Set some parameters for the location object.
[locationManager setDistanceFilter:kCLDistanceFilterNone];
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
}
and this is delegate :
#pragma mark - MKMapViewDelegate methods.
- (void)mapView:(MKMapView *)mv didAddAnnotationViews:(NSArray *)views
{
MKCoordinateRegion region;
region = MKCoordinateRegionMakeWithDistance(locationManager.location.coordinate,2000,2000);
[mv setRegion:region animated:YES];
}
Please any one help me.
What’s the problem exactly? Not getting a userLocation where you’re supposed to have or not moving the map region to the right place?
If it’s the first, it is mostly a tools issue, not a code issue:
If your location is in a gpx file inside your project you should be able to start at it by editing Scheme / Options / Allow Location Simulation / and choose your default Location
And you should have a DemoStart.gpx file in your project that looks like:
(Sorry, I’m too lazy to find Egypt’s exact coordinates).