2

Is it possible to add a CalloutAccessoryView to the default pin (pulsing blue dot, with accuracy cirle) when showing the user location. In the code below you create your own pin and add the 'pinView.rightCalloutAccessoryView' when the annotation is not the user location, can this be done when it is the user location but still using the default pin or do you have to use your own pins for this functionality?

- (MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id )annotation
{
    MKPinAnnotationView *pinView = nil;
    if(annotation != mapView.userLocation)
    {
        static NSString *defaultPinID = @"com.invasivecode.pin";
        pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
        if ( pinView == nil )
            pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:defaultPinID] autorelease];
        pinView.pinColor = MKPinAnnotationColorGreen;
        pinView.canShowCallout = YES;
        pinView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
        pinView.animatesDrop = YES;
    }
    else
        [mapView.userLocation setTitle:@"I am here"];

return pinView;
}

Thanks.

Till
  • 27,364
  • 13
  • 84
  • 120
user773805
  • 21
  • 1
  • Comment out the userLocation check and see what happens. – Rayfleck May 27 '11 at 23:58
  • `MKPinAnnotationView` is a helper class you can use for anything on the map, including your location. You're probably looking to change the pinColor to `MKPinAnnotationColor*` to differentiate it from the other pins on the map. And yes you can have accessory views. – Michael Kernahan May 28 '11 at 00:52
  • #Rayfleck. If I comment out the userLocation check it just uses my pin not the default blue pulsing pin. – user773805 May 28 '11 at 06:06
  • 1
    Michael I don't want to change the pinColor, just change the default pin to include a disclosure button. I want to see if its possible to keep the blue pulsing pin, but with the disclosure button. – user773805 May 28 '11 at 06:12

0 Answers0