wlach / nvpolyline

Example project for showing a zoomable/movable polyline annotation inside an iPhone MapKit view
http://navarra.ca/?p=786
Other
60 stars 19 forks source link

Polyline View overlaps other Annotation Views #2

Open leviathan opened 14 years ago

leviathan commented 14 years ago

I've added several other annotation views to my map view.

All annotation views within the MKMapView annotations array are in somewhat random order. This may cause some annotation views to be overlapped by the polyline view.

Here's a solution. Would you be so kind and incorporate this in your example.

Add this to your view controller, which serves as your MKMapViewDelegate:

# pragma mark -
# pragma mark - MKMapViewDelegate

- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views {
    for (int i=0; i<[views count]; i++) {
        MKAnnotationView *view = [views objectAtIndex:i];
        if ([view isKindOfClass:[NVPolylineAnnotationView class]]) {
            [[view superview] sendSubviewToBack:view];
        }
    }
}