私は以下のコードで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