Mac Developer Library

Developer

MapKit Framework Reference MKAnnotation Protocol Reference

Options
Deployment Target:

On This Page
Language:

MKAnnotation

The MKAnnotation protocol is used to provide annotation-related information to a map view. To use this protocol, you adopt it in any custom objects that store or represent annotation data. Each object then serves as the source of information about a single map annotation and provides critical information, such as the annotation’s location on the map. Annotation objects do not provide the visual representation of the annotation but typically coordinate (in conjunction with the map view’s delegate) the creation of an appropriate MKAnnotationView object to handle the display. More...

Inheritance


Not Applicable

Import Statement


import MapKit @import MapKit;

Availability


Available in OS X v10.9 and later.
  • The center point (specified as a map coordinate) of the annotation. (required) (read-only)

    Declaration

    Swift

    var coordinate: CLLocationCoordinate2D { get }

    Objective-C

    @property(nonatomic, readonly) CLLocationCoordinate2D coordinate

    Discussion

    Your implementation of this property must be key-value observing (KVO) compliant. For more information on how to implement support for KVO, see Key-Value Observing Programming Guide.

    Import Statement

    import MapKit

    Availability

    Available in OS X v10.9 and later.

  • Sets the new center point of the annotation.

    Declaration

    Swift

    optional func setCoordinate(_ newCoordinate: CLLocationCoordinate2D)

    Objective-C

    - (void)setCoordinate:(CLLocationCoordinate2D)newCoordinate

    Parameters

    newCoordinate

    The new center point for the annotation.

    Discussion

    Annotations that support dragging should implement this method to update the position of the annotation.

    If you implement this method, you must update the value of the coordinate in a key-value observing (KVO) compliant way. For more information on how to implement support for KVO, see Key-Value Observing Programming Guide.

    Import Statement

    import MapKit

    Availability

    Available in OS X v10.9 and later.

  • title title Property

    The string containing the annotation’s title.

    Declaration

    Swift

    optional var title: String! { get }

    Objective-C

    @property(nonatomic, readonly, copy) NSString *title

    Discussion

    Although this property is optional, if you support the selection of annotations in your map view, you are expected to provide this property. This string is displayed in the callout for the associated annotation view.

    Import Statement

    import MapKit

    Availability

    Available in OS X v10.9 and later.

  • subtitle subtitle Property

    The string containing the annotation’s subtitle.

    Declaration

    Swift

    optional var subtitle: String! { get }

    Objective-C

    @property(nonatomic, readonly, copy) NSString *subtitle

    Discussion

    This string is displayed in the callout for the associated annotation view.

    Import Statement

    import MapKit

    Availability

    Available in OS X v10.9 and later.