屏幕上的加载地图视图。
如果我们从左右移动地图
当我点击按钮
时,我需要立即在屏幕上显示当前位置我使用以下代码初始获取当前位置
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation{
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(userLocation.coordinate, 800, 800);
[self.mapView setRegion:[self.mapView regionThatFits:region] animated:YES];
// Add an annotation
MKPointAnnotation *point = [[MKPointAnnotation alloc] init];
point.coordinate = userLocation.coordinate;
point.title = @"Where am I?";
point.subtitle = @"I'm here!!!";
[self.mapView addAnnotation:point];
}
答案 0 :(得分:1)
。
- (void)gotoLocation
{
float spanX = 0.05;
float spanY = 0.05;
MKCoordinateRegion region;
region.center.latitude = mapView.userLocation.coordinate.latitude;
region.center.longitude = mapView.userLocation.coordinate.longitude;
region.span.latitudeDelta = spanX;
region.span.longitudeDelta = spanY;
[mapView setRegion:region animated:YES];
}