iPhone Map: Identifying Users Location
Posted
by senfo
on Stack Overflow
See other posts from Stack Overflow
or by senfo
Published on 2010-05-19T15:37:32Z
Indexed on
2010/05/19
15:40 UTC
Read the original article
Hit count: 300
I have a number of annotations on my map, in addition to the users current location. This works fine, except the default color for the users current location is the same as all of the other annotations. I'd like to make the pin green for the users current location so that it's uniquely identifiable from the other pins. How do I do this?
Bellow is the method I've been using (I can't find a way to determine which annotation is the users current location):
- (MKAnnotationView *)mapView:(MKMapView *)mapViewLocal viewForAnnotation:(id <MKAnnotation>)annotation {
static NSString *identifier = @"Pin";
MKPinAnnotationView *pinView = (MKPinAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
if (pinView == nil)
{
pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier] autorelease];
pinView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
pinView.animatesDrop = YES;
pinView.canShowCallout = YES;
}
else
{
pinView.annotation = annotation;
}
return pinView;
}
© Stack Overflow or respective owner