How to show user on Map using mapkit in IOS. This code only show the India on the map instead of coordinates defined.
mapView.delegate = self;
mapView.showsUserLocation = YES;
objLocationManager = [[CLLocationManager alloc] init];
objLocationManager.distanceFilter = kCLDistanceFilterNone;
objLocationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
objLocationManager.delegate = self;
#ifdef __IPHONE_8_0
if(IS_OS_8_OR_LATER) {
// Use one or the other, not both. Depending on what you put in info.plist
//[objLocationManager requestWhenInUseAuthorization];
[objLocationManager requestAlwaysAuthorization];
}
#endif
[objLocationManager startUpdatingLocation];
mapView.showsUserLocation = YES;
[mapView setMapType:MKMapTypeStandard];
[mapView setZoomEnabled:YES];
[mapView setScrollEnabled:YES];
mapView.delegate=self;
You are starting Location Updates and you will get your current location through it. But how will MKMapview know about the Location Changes?
For MKMap View to adopt Location changes you have to set delegate to MKMapview. That part you have done already, but you forgot the delegate method:
- (void)mapView:(MKMapView *)aMapView didUpdateUserLocation:(MKUserLocation *)aUserLocation {}
This delegate method will send your current location to MapView. That is all you need.
If you want to use the default Delegate method, then you have to place marker on map with a current coordinate received from CLLocation's Update Method.
If you are going to use default delegate method then don't forget to confirm MKMapViewDelegate.
Let us know if it works. I am sure it will. Have a good day.