I would like to remove all annotations from my mapview without the blue dot of my position. When I call:
[mapView removeAnnotations:mapView.annotations];
all annotations are removed.
In which way can I check (like a for loop on all the annotations) if the annotation is not the blue dot annotation?
EDIT (I've solved with this):
for (int i =0; i < [mapView.annotations count]; i++) {
if ([[mapView.annotations objectAtIndex:i] isKindOfClass:[MyAnnotationClass class]]) {
[mapView removeAnnotation:[mapView.annotations objectAtIndex:i]];
}
}
Best Answer
Looking at the MKMapView documentation, it seems like you have the annotations property to play with. It should be pretty simple to iterate through this and see what annotations you have :
You also have the
userLocation
property which gives you the annotation representing the user's location. If you go through the annotations and remember all of them which are not the user location, you can then remove them using theremoveAnnotations:
method :Hope this helps,
Sam