Note that there are some explanatory texts on larger screens.

plurals
  1. POTelling the difference between UserLocation Pin and user added pins
    text
    copied!<p>I am trying to solve a problem that I'm not sure how to solve. In my app, when the mapkit launches, I drop a pin at the user's current location. The mapkit delegates to viewForAnnotation which sets the pin's color which works fine. </p> <p>The issue I'm running into is I cannot tell the annotations apart so I can apply a different color to "user added locations" vs. my "current location" pin. I would like to add a button so they can delete any pins they add but not be able to delete their "current location" pin. I can't seem to figure out how to extract any identifiable pieces of information like title or subtitle of the pin. </p> <p>Thanks in advance for your help.</p> <p>Here's my code...</p> <pre><code> - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id &lt;MKAnnotation&gt;)annotation { NSLog(@"OAAssignmentGPSViewController.m : mapView viewForAnnotation"); if([annotation isKindOfClass: [MKUserLocation class]]) return nil; NSLog(@" mapView.userLocation.title = %@", self.mapView.userLocation.title); static NSString* annotationIdentifier = @"currentlocation"; MKPinAnnotationView *myPinView = (MKPinAnnotationView *)[self.mapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier]; if (!myPinView) { myPinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:nil] ; myPinView.pinColor = MKPinAnnotationColorRed; myPinView.canShowCallout = YES; myPinView.animatesDrop = YES; NSLog(@"mapView.description %@", self.mapView.userLocation.title); if( annotation != self.mapView.userLocation)&lt;&lt;&lt;&lt;&lt;----how do I check for UserLocation { myPinView.pinColor = MKPinAnnotationColorGreen; myPinView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; } } return myPinView; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload