作者:这辈子1015 | 来源:互联网 | 2023-05-16 05:11
IvegotamapViewwhichzoomstothecurrentlocationusingviewDidLoad:我有一个mapView,它使用viewDidLoa
I've got a mapView which zooms to the current location using viewDidLoad
:
我有一个mapView,它使用viewDidLoad缩放到当前位置:
#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;
}
This works fine. I've added a search bar and a function to jump to a specific address location. This works fine, too. I now want to add a button to jump back to the current location. Can you give me a hand, please?
这很好用。我添加了一个搜索栏和一个跳转到特定地址位置的函数。这也很好。我现在想要添加一个按钮来跳回当前位置。你可以帮我一把吗?
Cheers
5 个解决方案