点击按钮返回定位点
- (IBAction)backButtonClick:(id)sender {
// 方式一: 以动画方式设置用户跟踪模式返回
/*
MKUserTrackingModeNone = 0, // the user's location is not followed
MKUserTrackingModeFollow, // the map follows the user's location
MKUserTrackingModeFollowWithHeading __TVOS_PROHIBITED, // the map follows the user's location and heading
*/
[self.mapView setUserTrackingMode:MKUserTrackingModeFollow animated:YES];
// 方式二: 设置地图范围 到定位点
// 中心点为定位点经纬度
/**
*
typedef struct {
CLLocationCoordinate2D center; 中心点 确定地图的位置
MKCoordinateSpan span; 经纬度跨度 确定地图的大小
} MKCoordinateRegion;
*/
/**
*
typedef struct {
CLLocationDegrees latitudeDelta; 纬度跨度 1°=111km
CLLocationDegrees longitudeDelta; 经度跨度
} MKCoordinateSpan;
*/
// OC 中结构体不能直接赋值,所以先要取出来,设置后重新赋值回去
CLLocationCoordinate2D center = CLLocationCoordinate2DMake(self.mapView.userLocation.location.coordinate.latitude, self.mapView.userLocation.location.coordinate.longitude);
//跨度为地图当前的跨度
//设置地图范围
[self.mapView setRegion:MKCoordinateRegionMake(center, self.mapView.region.span) animated:YES];
}