我有哪些缩放到使用viewDidLoad
当前位置的MapView类:转至/缩放到当前位置的功能(MapKit)
#define METERS_PER_MILE 1609.344
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
[super viewDidLoad];
mapView.showsUserLocation=TRUE;
// zoom to a specific area
CLLocationCoordinate2D zoomLocation;
zoomLocation.latitude = -28.994167;
zoomLocation.longitude = 134.866944;
MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(zoomLocation, 1900*METERS_PER_MILE, 1900*METERS_PER_MILE);
MKCoordinateRegion adjustedRegion = [mapView regionThatFits:viewRegion];
// make sure the Google water mark is always visible
mapView.autoresizingMask =
(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
[mapView setRegion:adjustedRegion animated:YES];
mapView.delegate=self;
searchBar.delegate = self;
}
这工作得很好。我添加了一个搜索栏和一个功能来跳转到特定的地址位置。这工作也很好。我现在想添加一个按钮跳回到当前位置。你能帮我一下吗?
干杯
添加
yourMKMapView.showsUserLocation = true
是有一个叫setCenter功能? – carbonr@carbonr是的,有 –
[mapView setCenterCoordinate:mapView.userLocation.location.coordinate animated:YES]; – carbonr