码迷,mamicode.com
首页 > 其他好文 > 详细

UI中地图的使用

时间:2015-09-23 17:11:46      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:interface   manager   center   

@interface ViewController ()

{

    CLLocationManager *manager;

    

}

@end


@implementation ViewController


- (void)viewDidLoad {

    [super viewDidLoad];

    // Do any additional setup after loading the view, typically from a nib.


    manager = [[CLLocationManager alloc]init];

    [manager requestAlwaysAuthorization];

    

    MKMapView *mapView = [[MKMapView alloc]initWithFrame:self.view.bounds];

    mapView.delegate = self;

    mapView.mapType = MKMapTypeStandard;

    CLLocationCoordinate2D center = {39.9115696831,116.2396262413};

    MKCoordinateSpan span = {0.1, 0.1};

    MKCoordinateRegion region = {center, span};

    [mapView setRegion:region animated:YES];

    mapView.showsUserLocation = YES;

    [self.view addSubview:mapView];

    

}


#pragma mark-MKMapViewDelegate

- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view

{

    NSLog(@"view:%@",view);

}

- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation

{

    NSLog(@"userLocation:%@",userLocation);

}

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation

{

    NSLog(@"annotation:%@",annotation);

    return nil;

}



UI中地图的使用

标签:interface   manager   center   

原文地址:http://10594302.blog.51cto.com/10584302/1697500

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!