I have custom pin images for different locations, i can show all the different pin at the same time. But Proble is, when i show Current Location of the User, All the Pins color change.
here is the Code:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
if ([annotation isKindOfClass:[MKUserLocation class]])
return nil;
if ([annotation isKindOfClass:[MapAnnotation class]]) {
MKAnnotationView *test=[[MKAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:@"AnnotationIdentifier"];
test.canShowCallout = YES;
// test.animatesDrop = YES;
UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
test
.rightCalloutAccessoryView = rightButton;
switch (_pushpinTag) {
case 5:
test.image = [UIImage imageNamed:@"pushpin_green.png"];
break;
case 6:
test.image = [UIImage imageNamed:@"pushpin_blue.png"];
break;
case 7:
test.image = [UIImage imageNamed:@"pushpin_black.png"];
break;
case 8:
test.image = [UIImage imageNamed:@"pushpin_yellow.png"];
break;
case 3:
test.image = [UIImage imageNamed:@"pushpin_red.png"];
break;
default:
break;
}
return test;
}
}
Now on different button press, different Pins (with custom images) are shown. Lets say i Have pins with Green, Blue, Black and Yellow. I press button to show Green Pins, then For Blue, then for Black, all the Pins show in their respective images. But When i Press the button to show Users Current Location, all the Pins changes to the last press Pin, which was Black.
Here is the Code to show User's Current Location:
- (IBAction)currentLocationButton:(id)sender {
_mapView.showsUserLocation = YES;
[_mapView setUserTrackingMode:MKUserTrackingModeFollowWithHeading animated:YES];
}
Can anyone point out whats wrong am i doing?
Thank you everyone :)
_pushpinTag
and how is it set? – user467105