在3.1中,我一直在使用“快车”MapView制作地图图象,在向用户介绍这些图像之前,我可以轮流、作物等等。 在3.2和4.0中,这种技术不再奏效。 这里有一些说明问题的法典,随后是我的理论。
// create map view
_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;
// zoom in to something enough to fill the screen
MKCoordinateRegion region;
CLLocationCoordinate2D center = {30.267222, -97.763889};
region.center = center;
MKCoordinateSpan span = {0.1, 0.1 };
region.span = span;
_mapView.region = region;
// set scrollview content size to full the imageView
_scrollView.contentSize = _imageView.frame.size;
// force it to load
#ifndef __IPHONE_3_2
// in 3.1 we can render to an offscreen context to force a load
UIGraphicsBeginImageContext(_mapView.frame.size);
[_mapView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIGraphicsEndImageContext();
#else
// in 3.2 and above, the renderInContext trick doesn t work...
// this at least causes the map to render, but it s clipped to what appears to be
// the viewPort size, plus some padding
[self.view addSubview:_mapView];
#endif
当该地图装满时,我 s弄该地图,在我的滚动概览中加以uff击。
- (void)mapViewDidFinishLoadingMap:(MKMapView *)mapView {
NSLog(@"[MapBuilder] mapViewDidFinishLoadingMap");
// render the map to a UIImage
UIGraphicsBeginImageContext(mapView.bounds.size);
// the first sub layer is just the map, the second is the google layer, this sublayer structure might change of course
[[[mapView.layer sublayers] objectAtIndex:0] renderInContext:UIGraphicsGetCurrentContext()];
// we are done with the mapView at this point, we need its ram!
_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中不再奏效。 我发现的唯一事情是暂时增加这一看法的地图(即使之可见)。 问题是,地图只给屏幕的可见区域加一点dding。 框架/限值是罚款,但似乎“有益”优化了装货,以限制在屏幕上或靠近屏幕上看到的碎片。
如何迫使地图满负荷的想法? 是否有其他问题?