Authored by Hal Mueller

added properties to interim RMMarker to allow direct setting of fore/background text color

... ... @@ -155,6 +155,7 @@
// [markerManager addDefaultMarkerAt:coolPlace];
RMMarker *marker = [[RMMarker alloc]initWithKey:RMMarkerBlueKey];
[marker setTextForegroundColor:[UIColor blueColor]];
[marker setTextLabel:@"Hello"];
[markerManager addMarker:marker AtLatLong:[[mapView contents] mapCenter]];
[marker release];
... ...
... ... @@ -40,8 +40,15 @@ extern NSString * const RMMarkerRedKey;
NSObject* data; // provided for storage of arbitrary user data
// A label which comes up when you tap the marker
UIView* labelView;
UIView *labelView;
UIColor *textForegroundColor;
UIColor *textBackgroundColor;
}
@property (assign, nonatomic) RMXYPoint location;
@property (nonatomic, retain) NSObject* data;
@property (nonatomic, retain) UIView* labelView;
@property(nonatomic,retain) UIColor *textForegroundColor;
@property(nonatomic,retain) UIColor *textBackgroundColor;
+ (RMMarker*) markerWithNamedStyle: (NSString*) styleName;
+ (CGImageRef) markerImage: (NSString *) key;
... ... @@ -72,10 +79,6 @@ extern NSString * const RMMarkerRedKey;
- (void) dealloc;
@property (assign, nonatomic) RMXYPoint location;
@property (retain) NSObject* data;
@property (nonatomic, retain) UIView* labelView;
// Call this with either RMMarkerBlue or RMMarkerRed for the key.
+ (CGImageRef) markerImage: (NSString *) key;
... ...
... ... @@ -42,12 +42,25 @@ static CGImageRef _markerBlue = nil;
@synthesize location;
@synthesize data;
@synthesize labelView;
@synthesize textForegroundColor;
@synthesize textBackgroundColor;
+ (RMMarker*) markerWithNamedStyle: (NSString*) styleName
{
return [[[RMMarker alloc] initWithNamedStyle: styleName] autorelease];
}
// init
- (id)init
{
if (self = [super init]) {
labelView = nil;
textForegroundColor = [UIColor blackColor];
textBackgroundColor = [UIColor clearColor];
}
return self;
}
- (id) initWithCGImage: (CGImageRef) image
{
return [self initWithCGImage: image anchorPoint: CGPointMake(0.5, 1.0)];
... ... @@ -55,7 +68,7 @@ static CGImageRef _markerBlue = nil;
- (id) initWithCGImage: (CGImageRef) image anchorPoint: (CGPoint) _anchorPoint
{
if (![super init])
if (![self init])
return nil;
self.contents = (id)image;
... ... @@ -131,17 +144,19 @@ static CGImageRef _markerBlue = nil;
- (void) setTextLabel: (NSString*)text
{
CGPoint position = CGPointMake([self bounds].size.width / 2 - [text sizeWithFont:[UIFont systemFontOfSize:15]].width / 2, 4);
[self setTextLabel:text toPosition:position withFont:[UIFont systemFontOfSize:15] withTextColor:[UIColor blackColor] withBackgroundColor:[UIColor clearColor]];
[self setTextLabel:text toPosition:position withFont:[UIFont systemFontOfSize:15] withTextColor:[self textForegroundColor] withBackgroundColor:[self textBackgroundColor]];
}
- (void) setTextLabel: (NSString*)text toPosition:(CGPoint)position
{
[self setTextLabel:text toPosition:position withFont:[UIFont systemFontOfSize:15] withTextColor:[UIColor blackColor] withBackgroundColor:[UIColor clearColor]];
[self setTextLabel:text toPosition:position withFont:[UIFont systemFontOfSize:15] withTextColor:[self textForegroundColor] withBackgroundColor:[self textBackgroundColor]];
}
- (void) setTextLabel: (NSString*)text withFont:(UIFont*)font withTextColor:(UIColor*)textColor withBackgroundColor:(UIColor*)backgroundColor
{
CGPoint position = CGPointMake([self bounds].size.width / 2 - [text sizeWithFont:font].width / 2, 4);
[self setTextForegroundColor:textColor];
[self setTextBackgroundColor:backgroundColor];
[self setTextLabel:text toPosition:position withFont:font withTextColor:textColor withBackgroundColor:backgroundColor];
}
... ... @@ -154,6 +169,8 @@ static CGImageRef _markerBlue = nil;
textSize.height+4);
UILabel *aLabel = [[UILabel alloc] initWithFrame:frame];
[self setTextForegroundColor:textColor];
[self setTextBackgroundColor:backgroundColor];
[aLabel setNumberOfLines:0];
[aLabel setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[aLabel setBackgroundColor:backgroundColor];
... ... @@ -209,8 +226,10 @@ static CGImageRef _markerBlue = nil;
- (void) dealloc
{
self.labelView = nil;
self.data = nil;
self.data = nil;
self.labelView = nil;
self.textForegroundColor = nil;
self.textBackgroundColor = nil;
[super dealloc];
}
... ...