MKAnnotation Protocol Reference

Conforms to
Framework
/System/Library/Frameworks/MapKit.framework
Availability
Available in iOS 3.0 and later.
Companion guide
Declared in
MKAnnotation.h
Related sample code

Overview

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.

An object that adopts this protocol must implement the coordinate property. The other methods of this protocol are optional.

Tasks

Position Attributes

Title Attributes

Properties

coordinate

The center point (specified as a map coordinate) of the annotation. (required) (read-only)

@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.

Availability
  • Available in iOS 3.0 and later.
Declared In
MKAnnotation.h

subtitle

The string containing the annotation’s subtitle.

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

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

Availability
  • Available in iOS 5.0 and later.
Related Sample Code
Declared In
MKAnnotation.h

title

The string containing the annotation’s title.

@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.

Availability
  • Available in iOS 5.0 and later.
Related Sample Code
Declared In
MKAnnotation.h

Instance Methods

setCoordinate:

Sets the new center point of the annotation.

- (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.

Availability
  • Available in iOS 4.0 and later.
Declared In
MKAnnotation.h