In 3.1, I used the “off-screen” MKMapView to create map images that I can rotate, crop, etc., before presenting them to the user. In 3.2 and 4.0, this method no longer works completely correctly. Here is some code that illustrates the problem, and then my theory.
_mapView = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, MAP_FRAME_SIZE, MAP_FRAME_SIZE)];
_mapView.zoomEnabled = NO;
_mapView.scrollEnabled = NO;
_mapView.delegate = self;
_mapView.mapType = MKMapTypeSatellite;
MKCoordinateRegion region;
CLLocationCoordinate2D center = {30.267222, -97.763889};
region.center = center;
MKCoordinateSpan span = {0.1, 0.1 };
region.span = span;
_mapView.region = region;
_scrollView.contentSize = _imageView.frame.size;
#ifndef __IPHONE_3_2
UIGraphicsBeginImageContext(_mapView.frame.size);
[_mapView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIGraphicsEndImageContext();
#else
[self.view addSubview:_mapView];
#endif
when the map is loaded, I click it and write it to my scrollview
- (void)mapViewDidFinishLoadingMap:(MKMapView *)mapView {
NSLog(@"[MapBuilder] mapViewDidFinishLoadingMap");
UIGraphicsBeginImageContext(mapView.bounds.size);
[[[mapView.layer sublayers] objectAtIndex:0] renderInContext:UIGraphicsGetCurrentContext()];
_mapView.delegate = nil;
[_mapView release];
[_mapView removeFromSuperview];
_mapView = nil;
UIImage* mapImage = [UIGraphicsGetImageFromCurrentImageContext() retain];
UIGraphicsEndImageContext();
_imageView.image = mapImage;
[mapImage release], mapImage = nil;
}
, 3.1 . 3.2, 4.0. , , , (.. ). , , . / , , , "" , , .
, ? - ?