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

  • Home
  • SEARCH
  • 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 8545831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:52:57+00:00 2026-06-11T12:52:57+00:00

I add my annotations as follows: [mapView addAnnotations:annotationArray]; then I want to access each

  • 0

I add my annotations as follows:

 [mapView addAnnotations:annotationArray];  

then I want to access each and individual annotations on the mapView as follows:

for (id<MKAnnotation> ann in mapView.annotations)

the problem is annotations on map view is not added in a way linked list. That is why it is not returning in same order that I add annotations to annotationsArray.

to illustrate:,

 [annotationArray addObject: annotation1]; 

 [annotationArray addObject: annotation2];

 [annotationArray addObject: annotation3];

 [mapView addAnnotations:annotationArray];  

 for (id<MKAnnotation> ann in mapView.annotations)
 {

  //not returning in same order as added above//

  }

Is there a bug in mapView annotation?

original code:

    NSMutableArray *attrArray=[[NSMutableArray alloc]init];
for (NSArray *row in latt)
{
    NSNumber *attr=[row valueForKey:@"attr"];
    NSNumber *attr2=[attr valueForKey:@"ozone_level"];
    NSLog(@"values:%@",attr2);
    NSNumber *comp=[NSNumber numberWithInt:-1];
    if(attr2!=comp)
    {
        if([attrArray count]==0)
        {attrArray=[[NSMutableArray alloc]initWithObjects:attr2, nil];
        }
        else
        {
            [attrArray addObject:attr2];
        }
        NSNumber *latt2=[row valueForKey:@"lat"];
        NSNumber *longt2=[row valueForKey:@"lng"];
        CLLocationCoordinate2D coordinate;
        coordinate.latitude=latt2.doubleValue;
        coordinate.longitude=longt2.doubleValue;
        if(test<5)
        {
        Annotation *annotation = [[Annotation alloc] init];
        annotation.coordinate = coordinate;
        annotation.title = [attr2 stringValue];
        int colorvalue=[attr2 intValue];
        pinColor = [self colorForAcceleration2:colorvalue];
        annotation.color = pinColor;

            if([annotationArray count]==0)
            {
                annotationArray=[[NSMutableArray alloc]initWithObjects:annotation,nil];
               // NSMutableArray *ad =[[NSMutableArray alloc]init];
            }
            else 
            {
                [annotationArray addObject:annotation];

            }

        }

        test++;

    }//if attr2
}//for
if( test == 5)
{
  [mapView addAnnotations:annotationArray];  
}
if(test>=5)
{
    //for (id<MKAnnotation> ann in mapView.annotations)
    for(int i=0;i<5;i++)  
    {   //Annotation *a = (Annotation *)ann;
         Annotation *a = ((Annotation*)[annotationArray objectAtIndex:i]);

        //((Annotation *)mapView.annotations).
        NSLog(@"%@",((Annotation*)[annotationArray objectAtIndex:i]).title);
        NSLog(@"%@",[attrArray objectAtIndex:i]);
        //NSLog(@"annotation array size:%d",[annotationArray count]);
       // NSLog(@"attr array size:%d",[attrArray count]);
        if([((Annotation*)[annotationArray objectAtIndex:i]).title isEqualToString:[[attrArray objectAtIndex:i] stringValue]])
        {
        }
        else{
            MKAnnotationView *av1=[mapView viewForAnnotation:((Annotation*)[annotationArray objectAtIndex:i])];
                a.title=[NSString stringWithFormat:[[attrArray objectAtIndex:i] stringValue]];
                int colorvalue=[[attrArray objectAtIndex:i] intValue];
                pinColor = [self colorForAcceleration2:colorvalue];
                a.color=pinColor;
                av1.image=[ZSPinAnnotation pinAnnotationWithColor:a.color];
                av1.annotation=a;}//else

        }//for
    }//if
  • 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-06-11T12:52:58+00:00Added an answer on June 11, 2026 at 12:52 pm

    Is there a bug in mapView annotation?

    Not unless you can find some documentation that says a map view will preserve the order in which you added the annotations. MKMapView very probably stores them in some internal structure that can efficiently select just those annotations that will actually appear on the map.

    Don’t use a map view as your mechanism for storing annotations. Store them yourself in whatever order you like, so that you don’t have to rely non-existant behavior in MKMapView.

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

Sidebar

Related Questions

i have some problem when use MKAnnotation , I want to add a Annotation
I want to add annotations on my classes properties, and then iterate all my
I want to add annotations to a route between 2 locations on the map.
I have a map and a set of annotations, each with a 'parent' property.
I know that it is possible to add annotations to an iOS Map. Is
I'm trying to add annotations to NSMutableArray annToLoad so I can later perform [mapView
I have a multiplatform application and want to add audio annotations functionality. I am
I need to add annotations to existing HTML documents - best in the form
I add a EditText into a Linearlayout, for each ,I set a picture as
I'm trying to add Annotations to an array to place multiple pins on a

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.