MKMapView

2016-06-23  本文已影响80人  逆战逆的态度

使用前先引入 #import <MapKit/MapKit.h>

    MKMapView * mapView = [[MKMapView alloc] initWithFrame:self.view.bounds];
    
    mapView.mapType = MKMapTypeStandard;
    
    [mapView setZoomEnabled:YES];

    [mapView setScrollEnabled:YES];
    //显示用户当前的坐标
    mapView.showsUserLocation = YES;
    //1.先定义区域的中心点
    CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(28.2148, 112.893);
    //2.定义显示的范围(范围越小,地图越精确)
    MKCoordinateSpan span = MKCoordinateSpanMake(0.1, 0.1);
    //3.定义一个显示区域
    MKCoordinateRegion region = MKCoordinateRegionMake(coordinate, span);
    [mapView setRegion:region animated:YES];
    
上一篇下一篇

猜你喜欢

热点阅读