Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6222379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:18:13+00:00 2026-05-24T08:18:13+00:00

viewForAnnotation is not being called until I move or zoom in on the map.

  • 0

viewForAnnotation is not being called until I move or zoom in on the map. Because of this, my annotations do not show until the map is touched. Any idea why?

NSString *incident;
for (incident in weekFeed) {
     NSString *finalCoordinates = [[NSString alloc] initWithFormat:@"%@", [incident valueForKey:@"coordinates"]];

     NSArray *coordinatesArray = [finalCoordinates componentsSeparatedByString:@","]; 

     latcoord = (@"%@", [coordinatesArray objectAtIndex:0]);
     longcoord = (@"%@", [coordinatesArray objectAtIndex:1]);

     // Final Logs
     NSLog(@"Coordinates in NSString: [%@] - [%@]", latcoord, longcoord);

     CLLocationCoordinate2D coord;
     coord.latitude = [latcoord doubleValue];
     coord.longitude = [longcoord doubleValue];


     DisplayMap *ann = [[DisplayMap alloc] init]; 
     ann.title = [NSString stringWithFormat: @"%@", [incident valueForKey:@"incident_type"]];
     ann.subtitle = [NSString stringWithFormat: @"%@", [incident valueForKey:@"note"]];
     ann.coordinate = coord;

     [mapView addAnnotation:ann];

     [ann release];
}


// Custom Map Markers
-(MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation {

    if ([annotation isKindOfClass:[MKUserLocation class]])
        return nil;  //return nil to use default blue dot view

    static NSString *AnnotationViewID = @"annotationViewID";
    MKAnnotationView *annotationView = (MKAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:AnnotationViewID];

    if (annotationView == nil) {
        annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationViewID] autorelease];
        }

    annotationView.canShowCallout = YES;

    if ([annotationView.annotation.title isEqualToString:@"one"]) {
        UIImage *pinImage = [UIImage imageNamed:@"marker_1.png"];
        [annotationView setImage:pinImage];
        }

    if ([annotationView.annotation.title isEqualToString:@"two"]) {
        UIImage *pinImage = [UIImage imageNamed:@"marker_2.png"];
        [annotationView setImage:pinImage];
        }

    annotationView.annotation = annotation;
    return annotationView;
    }

- (void) mapView:(MKMapView *)mapV didAddAnnotationViews:(NSArray *)views {
    CGRect visibleRect = [mapV annotationVisibleRect]; 
    for (MKAnnotationView *view in views) {
        CGRect endFrame = view.frame;

        CGRect startFrame = endFrame; startFrame.origin.y = visibleRect.origin.y - startFrame.size.height;
        view.frame = startFrame;

        [UIView beginAnimations:@"drop" context:NULL]; 
        [UIView setAnimationDuration:0.4];

        view.frame = endFrame;

        [UIView commitAnimations];
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T08:18:14+00:00Added an answer on May 24, 2026 at 8:18 am

    I solved it by using [self performSelectorInBackground:@selector(loadEverything) withObject:self]; instead of detachThreadSelector. That code (in viewDidLoad) wasn’t originally posted.

    Thanks for helping everyone!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working with Mapkit and I have to show annotations in the map
I can perfectly load my map view with annotations the first time. However, if
This is my -mapView:viewForAnnotation method which drops pins when i create annotation views. But
I've got a MKMapView and I'm adding annotations like this: for (NSDictionary *tmp in
I am displaying a pin on the map but I am not able to
enabled nszombies Is there any additional information anyone can see in this debug log
I'm currently adding annotations to my map through a loop... but the annotations are
I have a map view with pins annotations into it. I need to pass
I have a map loading up on my iPhone which shows pin annotations. I
In my code, the - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation method is not getting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.