ユーザーの緯度と経度の座標をキャプチャしただけの地図を表示してから、地図上でユーザーにズームインしようとしています。ユーザーの座標をキャプチャすることはできますが、ユーザーの場所にズームインした地図を表示したり、地図をユーザーの中央に配置したりすることはできません。残念ながら、私は遠くからユーザーを示す地図しか見ることができません。私の関連するコードは次のとおりです。
userLoc
.hファイルでタイプCLLocationCoordinate2Dを宣言します。次に、.mファイルに次のものがあります。
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
NSLog(@"didUpdateToLocation: %@", newLocation);
CLLocation *currentLocation = newLocation;
userLoc = newLocation.coordinate;
[locationManager stopUpdatingLocation];
[self showCurrentLocation];
if (currentLocation != nil) {
userLongitude = [NSString stringWithFormat:@"%.8f", currentLocation.coordinate.longitude];
userLatitude = [NSString stringWithFormat:@"%.8f", currentLocation.coordinate.latitude];
}
NSLog(@"User Latitude is %@", userLatitude);
NSLog(@"User Longitude is %@", userLongitude);
}
次に、実際のマップを表示する次のメソッドがあります。
-(void) showCurrentLocation {
mapView = [[MKMapView alloc] initWithFrame:CGRectMake(0, 55, 320, 425)];
MKCoordinateRegion region = mapView.region;
MKCoordinateSpan span;
region.center = userLoc;
span.latitudeDelta = 0.02;
span.longitudeDelta = 0.02;
region.span=span;
[mapView setMapType:MKMapTypeStandard];
[mapView setZoomEnabled:YES];
[mapView setScrollEnabled:YES];
[mapView setShowsUserLocation:YES];
[self.view addSubview:mapView];
}
私が言ったように、私はユーザーの位置を示す地図を見ることができますが、地図はズームインせず、地図をユーザーの中央に配置しません。誰もが理由を見ることができますか?