KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a map view with a large quantity of annotations (3000+), when the user is zoomed to a reasonable level all is well and fast. Although when the user zooms out and a large quanitiy of annotations come into view there is a lot of slow down due to the sheer amount of annotations being shown at once. What is the best way to handle this? The current solution i am using: - (void)mapView:(MKMapView *)_mapView regionDidChangeAnimated:(BOOL)animated { NSArray *annotations = [_mapView annotations]; MapAnnotation *annotation = nil; for (int i=0; i<[annotations count]; i++) { annotation = (MapAnnotation*)[annotations objectAtIndex:i]; if (_mapView.region.span.latitudeDelta > .010) { [[_mapView viewForAnnotation:annotation] setHidden:YES]; warningLabel.hidden = NO; } else { [[_mapView viewForAnnotation:annotation] setHidden:NO]; warningLabel.hidden = YES; } } } Works great although due to the sheer size of the loop this causes a lot of slow down when zooming in and out and scrolling around. I can't seem to think of a better way to handle this, is there a way to only loop through the annotations currently being displayed or something along those lines to reduce the size of the loop?
Tags (comma-separated)
Save Edits
Cancel