Authored by Justin R. Miller

enhanced customizability for point, polyline, and polygon annotations

... ... @@ -30,7 +30,7 @@
@class RMMapView, RMMapLayer, RMQuadTreeNode;
/** 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 can be set ahead of time using the annotation's layer property, or, in the recommended approach, can be provided by an RMMapView's delegate when first needed for display.
/** 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. */
@interface RMAnnotation : NSObject
... ...
... ... @@ -28,9 +28,12 @@
#import "RMAnnotation.h"
/** An RMPointAnnotation is used to represent a single point on a map. The annotation will automatically have a layer created when needed that displays an RMMarker with a default point icon.
/** An RMPointAnnotation is used to represent a single point on a map. The annotation will automatically have a layer created when needed that displays an RMMarker with either a default point icon or the supplied image.
*
* If you wish to customize the appearance, you should instead create an RMAnnotation and configure its layer directly. Providing a layer manually for instances of RMPointAnnotation will not have any effect. */
* If you wish to customize the layer appearance in more detail, you should instead create an RMAnnotation and configure its layer directly. Providing a layer manually for instances of RMPointAnnotation will not have any effect. */
@interface RMPointAnnotation : RMAnnotation
/** An image for the annotation's point. */
@property (nonatomic, strong) UIImage *image;
@end
... ...
... ... @@ -54,4 +54,14 @@
return [super layer];
}
- (void)setImage:(UIImage *)image
{
[(RMMarker *)[self layer] replaceUIImage:image];
}
- (UIImage *)image
{
return [UIImage imageWithCGImage:(CGImageRef)[self layer].contents];
}
@end
... ...
... ... @@ -32,7 +32,7 @@
*
* When creating a polygon, you can mask out portions of the polygon by specifying one or more interior polygons. Areas that are masked by an interior polygon are not considered part of the polygon’s occupied area.
*
* If you wish to customize the appearance, you should instead create an RMAnnotation and configure its layer directly. Providing a layer manually for instances of RMPolygonAnnotation will not have any effect. */
* If you wish to customize the layer appearance in more detail, you should instead create an RMAnnotation and configure its layer directly. Providing a layer manually for instances of RMPolygonAnnotation will not have any effect. */
@interface RMPolygonAnnotation : RMShapeAnnotation
/** Initialize a polygon annotation.
... ...
... ... @@ -28,9 +28,9 @@
#import "RMShapeAnnotation.h"
/** An RMPolylineAnnotation is a concrete subclass of RMShapeAnnotation that is used to represent a shape consisting of one or more points that define connecting line segments. The points are connected end-to-end in the order they are provided. The first and last points are not connected to each other. The annotation will automatically have a layer created when needed that displays an RMShape.
/** An RMPolylineAnnotation is a concrete subclass of RMShapeAnnotation that is used to represent a shape consisting of one or more points that define connecting line segments. The points are connected end-to-end in the order they are provided. The first and last points are not connected to each other. The annotation will automatically have a layer created when needed that displays an RMShape.
*
* If you wish to customize the appearance, you should instead create an RMAnnotation and configure its layer directly. Providing a layer manually for instances of RMPolylineAnnotation will not have any effect. */
* If you wish to customize the layer appearance in more detail, you should instead create an RMAnnotation and configure its layer directly. Providing a layer manually for instances of RMPolylineAnnotation will not have any effect. */
@interface RMPolylineAnnotation : RMShapeAnnotation
@end
... ...
... ... @@ -42,4 +42,10 @@
/** The array of points associated with the shape. (read-only) */
@property (nonatomic, readonly, strong) NSArray *points;
/** A color for the annotation's shape. */
@property (nonatomic, strong) UIColor *lineColor;
/** A line width for the annotation's shape. */
@property (nonatomic, assign) CGFloat lineWidth;
@end
... ...
... ... @@ -28,6 +28,8 @@
#import "RMShapeAnnotation.h"
#import "RMShape.h"
@implementation RMShapeAnnotation
@synthesize points=_points;
... ... @@ -49,4 +51,24 @@
return self;
}
- (void)setLineColor:(UIColor *)lineColor
{
[(RMShape *)[self layer] setLineColor:lineColor];
}
- (UIColor *)lineColor
{
return ((RMShape *)[self layer]).lineColor;
}
- (void)setLineWidth:(CGFloat)lineWidth
{
[(RMShape *)[self layer] setLineWidth:lineWidth];
}
- (CGFloat)lineWidth
{
return ((RMShape *)[self layer]).lineWidth;
}
@end
... ...