RMAnnotation Class Reference
Inherits from | NSObject |
Declared in | RMAnnotation.h |
Overview
An RMAnnotation defines a container for annotation data to be placed on a map. At a future point in time, depending on map use, a visible layer may be requested and displayed for the annotation. The layer is provided by an RMMapView’s delegate when first needed for display.
Subclasses of RMAnnotation such as RMPointAnnotation, RMPolylineAnnotation, and RMPolygonAnnotation are useful for simple needs such as easily putting points and shapes onto a map view. They manage their own layer and don’t require configuration in the map view delegate in order to be displayed.
Tasks
Configuration Basic Annotation Properties
-
coordinate
property -
title
property -
subtitle
property -
userInfo
property -
annotationType
property -
annotationIcon
property -
position
property -
absolutePosition
property -
enabled
property
Representing an Annotation Visually
-
layer
property
Annotation Clustering
-
clusteringEnabled
property -
isClusterAnnotation
property -
clusteredAnnotations
property
Filtering Types of Annotations
-
isUserLocationAnnotation
property
Initializing Annotations
Querying Annotation Visibility
-
isAnnotationOnScreen
property -
– isAnnotationWithinBounds:
-
isAnnotationVisibleOnScreen
property
Properties
absolutePosition
The annotation’s absolute location on screen taking into account possible map rotation.
@property (nonatomic, readonly, assign) CGPoint absolutePosition
Discussion
The annotation’s absolute location on screen taking into account possible map rotation.
Declared In
RMAnnotation.h
annotationIcon
An arbitrary icon image for the annotation. Useful to pass an image at annotation creation time for use in the layer at a later time.
@property (nonatomic, strong) UIImage *annotationIcon
Discussion
An arbitrary icon image for the annotation. Useful to pass an image at annotation creation time for use in the layer at a later time.
Declared In
RMAnnotation.h
annotationType
An arbitrary string representing the type of annotation. Useful for determining which layer to draw for the annotation when requested in the delegate. Cluster annotations, which are automatically created by a map view, will automatically have an annotationType of RMClusterAnnotation
.
@property (nonatomic, strong) NSString *annotationType
Discussion
An arbitrary string representing the type of annotation. Useful for determining which layer to draw for the annotation when requested in the delegate. Cluster annotations, which are automatically created by a map view, will automatically have an annotationType of RMClusterAnnotation
.
Declared In
RMAnnotation.h
clusteredAnnotations
If the annotation is a cluster annotation, returns an array containing the annotations in the cluster. Returns nil
if the annotation is not a cluster annotation.
@property (nonatomic, readonly, assign) NSArray *clusteredAnnotations
Discussion
If the annotation is a cluster annotation, returns an array containing the annotations in the cluster. Returns nil
if the annotation is not a cluster annotation.
Declared In
RMAnnotation.h
clusteringEnabled
Whether the annotation should be clustered when map view clustering is enabled. Defaults to YES
.
@property (nonatomic, assign) BOOL clusteringEnabled
Discussion
Whether the annotation should be clustered when map view clustering is enabled. Defaults to YES
.
Declared In
RMAnnotation.h
coordinate
The annotation’s location on the map.
@property (nonatomic, assign) CLLocationCoordinate2D coordinate
Discussion
The annotation’s location on the map.
Declared In
RMAnnotation.h
enabled
Whether touch events for the annotation’s layer are recognized. Defaults to YES
.
@property (nonatomic, assign, getter=isEnabled) BOOL enabled
Discussion
Whether touch events for the annotation’s layer are recognized. Defaults to YES
.
Declared In
RMAnnotation.h
isAnnotationOnScreen
Whether the annotation is currently on the screen, regardless if clustered or not.
@property (nonatomic, readonly) BOOL isAnnotationOnScreen
Discussion
Whether the annotation is currently on the screen, regardless if clustered or not.
Declared In
RMAnnotation.h
isAnnotationVisibleOnScreen
Whether the annotation is currently visible on the screen. An annotation is not visible if it is either offscreen or currently in a cluster.
@property (nonatomic, readonly) BOOL isAnnotationVisibleOnScreen
Discussion
Whether the annotation is currently visible on the screen. An annotation is not visible if it is either offscreen or currently in a cluster.
Declared In
RMAnnotation.h
isClusterAnnotation
Whether an annotation is an automatically-managed cluster annotation.
@property (nonatomic, readonly, assign) BOOL isClusterAnnotation
Discussion
Whether an annotation is an automatically-managed cluster annotation.
Declared In
RMAnnotation.h
isUserLocationAnnotation
Whether the annotation is related to display of the user’s location. Useful for filtering purposes when providing annotation layers in the delegate.
@property (nonatomic, readonly) BOOL isUserLocationAnnotation
Discussion
Whether the annotation is related to display of the user’s location. Useful for filtering purposes when providing annotation layers in the delegate.
There are three possible user location annotations, depending on current conditions: the user dot, the pulsing halo, and the accuracy circle. All may have custom layers provided, but if you only want to customize the user dot, you should check that the annotation is a member of the RMUserLocation class in order to ensure that you are altering only the correct annotation layer.
Declared In
RMAnnotation.h
layer
An object representing the annotation’s visual appearance.
@property (nonatomic, strong) RMMapLayer *layer
Discussion
An object representing the annotation’s visual appearance.
Declared In
RMAnnotation.h
position
The annotation’s current location on screen relative to the map. Do not set this directly unless during temporary operations such as animations, but rather use the coordinate property to permanently change the annotation’s location on the map.
@property (nonatomic, assign) CGPoint position
Discussion
The annotation’s current location on screen relative to the map. Do not set this directly unless during temporary operations such as animations, but rather use the coordinate property to permanently change the annotation’s location on the map.
Declared In
RMAnnotation.h
subtitle
The annotation’s subtitle.
@property (nonatomic, strong) NSString *subtitle
Discussion
The annotation’s subtitle.
Declared In
RMAnnotation.h
Class Methods
annotationWithMapView:coordinate:andTitle:
Create and initialize an annotation.
+ (instancetype)annotationWithMapView:(RMMapView *)aMapView coordinate:(CLLocationCoordinate2D)aCoordinate andTitle:(NSString *)aTitle
Parameters
- aMapView
The map view on which to place the annotation.
- aCoordinate
The location for the annotation.
- aTitle
The annotation’s title.
Return Value
An annotation object, or nil
if an annotation was unable to be created.
Discussion
Create and initialize an annotation.
Declared In
RMAnnotation.h
Instance Methods
initWithMapView:coordinate:andTitle:
Initialize an annotation.
- (id)initWithMapView:(RMMapView *)aMapView coordinate:(CLLocationCoordinate2D)aCoordinate andTitle:(NSString *)aTitle
Parameters
- aMapView
The map view on which to place the annotation.
- aCoordinate
The location for the annotation.
- aTitle
The annotation’s title.
Return Value
An initialized annotation object, or nil
if an annotation was unable to be initialized.
Discussion
Initialize an annotation.
Declared In
RMAnnotation.h