Note that there are some explanatory texts on larger screens.

plurals
  1. POMaximum number of annotations (MKAnnotation) that can be drawn on MKMapView?
    primarykey
    data
    text
    <p>I want to add a number of annotations(arround 500) on a mapview but the maximum it seems to display is 100. If I go beyond 100, <strong>viewForAnnotation</strong> delegate method is not called. However it works perfectly for annotations below 100.</p> <p>here is the code: (works only when count of <strong>annotationArray</strong> array is less than 101)</p> <pre><code>_allPoints = [[NSMutableArray alloc] init]; NSString* responseFile = [[NSBundle mainBundle] pathForResource:@"Datafile" ofType:@"txt"]; NSData *sampleData = [NSData dataWithContentsOfFile:responseFile]; if (sampleData) { NSError* error; NSDictionary* json = [NSJSONSerialization JSONObjectWithData:sampleData options:kNilOptions error:&amp;error]; NSArray* response = [json objectForKey:@"response"]; for (NSDictionary *lineDict in response) { if ([[lineDict objectForKey:@"data"] isKindOfClass:[NSArray class]]) { SinglePoint *singlePoint = [[SinglePoint alloc] initWithDictionary:lineDict]; [_allPoints addObject:singlePoint]; } else { NSLog(@"Error"); } } } _mapView = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; [_mapView setDelegate:self]; [self.view addSubview:_mapView]; NSMutableArray *annotationArray = [[NSMutableArray alloc] init]; for (int i=0; i&lt;[_allPoints count]; i++) { SinglePoint *singlePoint = [_allPoints objectAtIndex:i]; NVPolylineAnnotation *annotation = [[NVPolylineAnnotation alloc] initWithPoint:singlePoint mapView:_mapView]; [annotationArray addObject:annotation]; } [_mapView addAnnotations:(NSArray *)annotationArray]; CLLocationCoordinate2D centerCoord = { 28.632747, 77.219982 }; [_mapView setCenterCoordinate:centerCoord zoomLevel:12 animated:NO]; </code></pre> <p>The delegate method is:</p> <p><strong>EDIT:</strong> As per comments, started reusing the view but with no luck :(</p> <pre><code>if ([annotation isKindOfClass:[NVPolylineAnnotation class]]) { static NSString *viewIdentifier = @"annotationView"; NVPolylineAnnotationView *annotationView = (NVPolylineAnnotationView *) [mapView dequeueReusableAnnotationViewWithIdentifier:viewIdentifier]; if (annotationView == nil) { annotationView = [[NVPolylineAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:viewIdentifier mapView:_mapView]; } return annotationView; } return nil; </code></pre> <p>I could not find any restriction in the documentation or anywhere else. Could it be memory issue?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload