1
我使用下面的代码在iPad上测试过。MKOverlayView性能问题。什么也不做。但是缓慢
如果我像下面的代码一样添加MyOverlay,那么即使在drawMapRect中什么都不做,默认地图图块的MKMapView加载速度会变慢。
如果我从MKMapView中删除MyOverlay,默认地图块的加载会再次变快。
我不知道在调用drawMapRect时后台做了什么。
或下面的代码有任何性能问题?
[代码]
@implementation MyOverlay
-(id) init
{
self = [super init];
boundingMapRect = MKMapRectWorld;
boundingMapRect.origin.x += 1048600.0;
boundingMapRect.origin.y += 1048600.0;
coordinate = CLLocationCoordinate2DMake(0, 0);
return self;
}
...
@end
@implementation MyOverlayView
- (id) initWithOverlay:(id<MKOverlay>)overlay
{
self = [super initWithOverlay:overlay];
...
return self;
}
- (BOOL) canDrawMapRect:(MKMapRect) sm zoomScale:(MKZoomScale)zoomScale
{
return true;
}
- (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext: CGContextRef)context
{
return; // do nothing, but map loading become slower 'much'.
}
@end