Reputation: 1046
Hi I have the following problem!
I do add a lot of Overlays to my MKMapView!
For example I add 150 Overlays, but for some reason not all of them show up!
I know that mapView:viewForOverlay:
gets called 150 times.
I found out that if I add this: [NSThread sleepForTimeInterval:1]
to the method where all my overlays are created all the overlays show up.
so can it be that the overlays being added to fast? or what could be the problem?
all the overlays are created in a background thread like this!
MKPolyline* routeLine;
....
....
dispatch_async(dispatch_get_main_queue(), ^{
[self.myMKMapView addOverlay:routeLine];
});
and this is the mapView:viewForOverlay:
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay
{
MKOverlayView* overlayView = nil;
MKPolylineView * rLV = [[[MKPolylineView alloc] initWithPolyline:overlay]autorelease];
rLV.fillColor = [UIColor blueColor];
rLV.strokeColor = [UIColor blueColor];
rLV.lineWidth = 1;
rLV.alpha = 0.5;
overlayView = rLV;
return overlayView;
}
Upvotes: 0
Views: 1498
Reputation: 7417
If you're calling addOverlay:
multiple times (and queueing up hundreds of blocks on the main thread), you may get better results calling the addOverlays:
method with an array instead.
Upvotes: 6