1

以下のコードでiPadでテストしました。

以下のコードのように 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
4

1 に答える 1