I am using MKMapView on my application. i need to show current location on simulator.
is it possible. to show current location on simulator.
self.mapView.delegate = self;
self.mapView.showsUserLocation = YES;
This will show the current location in MkMapview
.
If you are using Interface Builder,In the Attributes Inspector , we have an option Behaviour
which has an option Show User Location
, on checking that option will also do the same.
If you are not able to see in simulator,
With CLLocationManager
also we can get the current location,
Import Corelocation
FrameWork to the project
In .h
file
#import
@property (nonatomic, strong) CLLocationManager *locationManager;
@property (nonatomic, strong) CLLocation* currentLocation;
In .m
file
if ([CLLocationManager locationServicesEnabled] )
{
if (self.locationManager == nil )
{
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
self.locationManager.distanceFilter = kDistanceFilter; //kCLDistanceFilterNone// kDistanceFilter;
}
[self.locationManager startUpdatingLocation];
}
The delegate function :
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
self.currentLocation = [locations lastObject];
// here we get the current location
}
Hope this answer may help you.