what i need for my app is, to display my current location on my mapview by using location service, here is my code
.h
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
@interface MapDirectoryViewController : UIViewController <MKMapViewDelegate, CLLocationManagerDelegate>
@property (weak, nonatomic) IBOutlet MKMapView *myMapView;
- (IBAction)backAction:(id)sender;
@end
.m
@interface MapDirectoryViewController ()
@end
@implementation MapDirectoryViewController
{
MKCoordinateRegion myRegion;
CLLocationCoordinate2D center;
MKCoordinateSpan span;
NSMutableArray *locations;
CLLocationCoordinate2D location;
Annotation *myAnnoation;
}
@synthesize myMapView;
- (void)viewDidLoad {
[super viewDidLoad];
myMapView.showsUserLocation = YES;
[myMapView setShowsUserLocation:YES];
[myMapView setCenterCoordinate:myMapView.userLocation.location.coordinate animated:YES];
}
#delegation
-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
//what do i need to do in here?
}
what i need excatly is to get blue dot to show up on map and make the dot as center of the map when app loads,
as you can see in my viewdidload, i tried many way to active the user current location, but none of them works...
and i realise one more thing in my actual iphone6, under general, my app doesnt have 'location' option there so i cant phycially go to active it.... e.g google map or facebook app they all have 'location' option under general app config...
any advise? any code example would be really helpful, thank you very much.
solution: 1, edit the source code of the Info.Plist with Right click > open as > Source code and add these lines:
2,
now it get me the current location with blue dot , and calling deleagation method correctly in ios 8