2
votes

I am trying to display my annotations that I have loading using MapKit in a particular order. Basically I have one pin out of about 50 that is slightly overlaying the other and I want to bring the one that obscured to the front.

As far as I can see changing the order of the annotations does nothing and it seems to display annotations from left to right with those furthest the right of the screen at the foreground if that makes sense. Turning the drop animation off also makes no difference.

Anyone know a way to re-roder the way in which the annotations appear?

Thanks

1

1 Answers

1
votes

I fixed it using this method, and specifying what pins to bring to the foreground:

- (void) mapView:(MKMapView *)aMapView didAddAnnotationViews:(NSArray *)views
{
for (MKPinAnnotationView *view in views)
    {
        //Bring red and purple pins to front (Foreground)
        if (view.annotation == myAnnotation31 || view.annotation == myAnnotation5 || view.annotation == myAnnotation17)
        {
            [view bringSubviewToFront:view];
        }
        else
        {
            [[view superview] sendSubviewToBack:view];
        }
    }
}