当你初始化地图试图中心 你应该指定的初始区域 一个区域被定义为中心点 水平 和 垂直距离 称为跨度
例如
[self.mapViewsetRegion:MKCoordinateRegionMakeWithDistance(CLLocationCoordinate2DMake(30.281843,120.102193),10,10)animated:YES];
实现mapView的代理方法《MKMapViewDelegate》
self.mapView.showUserLocation=YES;
self.mapView.delegate=self;
得道用户位置坐标
CLLocationCoordinate2D coords=self.mapView.usrLocation.locaiton.coordinate;
然后实现代理方法
-(void)mapView:(MKMapView*)mapView didUpdateUserLocation:(MKUserLocation*)usrLocation{
}
一般只需要写self。mapView。userTrackingMode=MKUserTrackingModeFollow即可就可以到达当前位置
//在地图上添加大头针的方法
MKPointAnnotation *ann = [[MKPointAnnotation alloc] init];
ann.coordinate = CLLocationCoordinate2DMake(23.134844f, 113.317290f);
[ann setTitle:@"我的位置"];
[self.mapView addAnnotation:ann];
[self.mapView setRegion:MKCoordinateRegionMakeWithDistance(CLLocationCoordinate2DMake(23.134844f, 113.317290f), 1000, 1000) animated:YES];