MKMapView

使用前先引入 #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];
    
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容