I'm making an applikation that will put pins/annotations in a mapview. When the user is getting close to a pin, I want the pin to change color. Everything works fine, the pins is placed where I want and I get an alert message when I get close enough. But I'm not sure how to update the pin color. Do I have to remove the annotations and replace them? Seems unnecessary, all I'm looking for is some kind of update/refresh the mapview without having to replace annotations.
CLLocation *place =[[CLLocation alloc] initWithCoordinate:location altitude:1 horizontalAccuracy:1 verticalAccuracy:-1 timestamp:nil];
AddresAnnotation *ann = [[AddresAnnotation alloc] initWithCoordinate:place.coordinate];
[ann setTitle:[rows placeName]];
[mapView addAnnotation:ann];
location is a CLLocationCoordinate2D
rows is an object containing the different locations and its information
Here's the mapView delegate method: (not sure why the last "}" is outside of the code sample)
-(MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
if (annotation != self.mapView.userLocation) {
annView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"Plats"] autorelease];
[annView setPinColor:MKPinAnnotationColorRed];
annView.animatesDrop = TRUE;
annView.canShowCallout = YES;
return annView;
} else {
zoomButton.enabled = TRUE;
return nil;
}
}