Authored by Hal Mueller

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

@@ -155,6 +155,7 @@ @@ -155,6 +155,7 @@
155 // [markerManager addDefaultMarkerAt:coolPlace]; 155 // [markerManager addDefaultMarkerAt:coolPlace];
156 156
157 RMMarker *marker = [[RMMarker alloc]initWithKey:RMMarkerBlueKey]; 157 RMMarker *marker = [[RMMarker alloc]initWithKey:RMMarkerBlueKey];
  158 + [marker setTextForegroundColor:[UIColor blueColor]];
158 [marker setTextLabel:@"Hello"]; 159 [marker setTextLabel:@"Hello"];
159 [markerManager addMarker:marker AtLatLong:[[mapView contents] mapCenter]]; 160 [markerManager addMarker:marker AtLatLong:[[mapView contents] mapCenter]];
160 [marker release]; 161 [marker release];
@@ -40,8 +40,15 @@ extern NSString * const RMMarkerRedKey; @@ -40,8 +40,15 @@ extern NSString * const RMMarkerRedKey;
40 NSObject* data; // provided for storage of arbitrary user data 40 NSObject* data; // provided for storage of arbitrary user data
41 41
42 // A label which comes up when you tap the marker 42 // A label which comes up when you tap the marker
43 - UIView* labelView; 43 + UIView *labelView;
  44 + UIColor *textForegroundColor;
  45 + UIColor *textBackgroundColor;
44 } 46 }
  47 +@property (assign, nonatomic) RMXYPoint location;
  48 +@property (nonatomic, retain) NSObject* data;
  49 +@property (nonatomic, retain) UIView* labelView;
  50 +@property(nonatomic,retain) UIColor *textForegroundColor;
  51 +@property(nonatomic,retain) UIColor *textBackgroundColor;
45 52
46 + (RMMarker*) markerWithNamedStyle: (NSString*) styleName; 53 + (RMMarker*) markerWithNamedStyle: (NSString*) styleName;
47 + (CGImageRef) markerImage: (NSString *) key; 54 + (CGImageRef) markerImage: (NSString *) key;
@@ -72,10 +79,6 @@ extern NSString * const RMMarkerRedKey; @@ -72,10 +79,6 @@ extern NSString * const RMMarkerRedKey;
72 79
73 - (void) dealloc; 80 - (void) dealloc;
74 81
75 -@property (assign, nonatomic) RMXYPoint location;  
76 -@property (retain) NSObject* data;  
77 -@property (nonatomic, retain) UIView* labelView;  
78 -  
79 // Call this with either RMMarkerBlue or RMMarkerRed for the key. 82 // Call this with either RMMarkerBlue or RMMarkerRed for the key.
80 + (CGImageRef) markerImage: (NSString *) key; 83 + (CGImageRef) markerImage: (NSString *) key;
81 84
@@ -42,12 +42,25 @@ static CGImageRef _markerBlue = nil; @@ -42,12 +42,25 @@ static CGImageRef _markerBlue = nil;
42 @synthesize location; 42 @synthesize location;
43 @synthesize data; 43 @synthesize data;
44 @synthesize labelView; 44 @synthesize labelView;
  45 +@synthesize textForegroundColor;
  46 +@synthesize textBackgroundColor;
45 47
46 + (RMMarker*) markerWithNamedStyle: (NSString*) styleName 48 + (RMMarker*) markerWithNamedStyle: (NSString*) styleName
47 { 49 {
48 return [[[RMMarker alloc] initWithNamedStyle: styleName] autorelease]; 50 return [[[RMMarker alloc] initWithNamedStyle: styleName] autorelease];
49 } 51 }
50 52
  53 +// init
  54 +- (id)init
  55 +{
  56 + if (self = [super init]) {
  57 + labelView = nil;
  58 + textForegroundColor = [UIColor blackColor];
  59 + textBackgroundColor = [UIColor clearColor];
  60 + }
  61 + return self;
  62 +}
  63 +
51 - (id) initWithCGImage: (CGImageRef) image 64 - (id) initWithCGImage: (CGImageRef) image
52 { 65 {
53 return [self initWithCGImage: image anchorPoint: CGPointMake(0.5, 1.0)]; 66 return [self initWithCGImage: image anchorPoint: CGPointMake(0.5, 1.0)];
@@ -55,7 +68,7 @@ static CGImageRef _markerBlue = nil; @@ -55,7 +68,7 @@ static CGImageRef _markerBlue = nil;
55 68
56 - (id) initWithCGImage: (CGImageRef) image anchorPoint: (CGPoint) _anchorPoint 69 - (id) initWithCGImage: (CGImageRef) image anchorPoint: (CGPoint) _anchorPoint
57 { 70 {
58 - if (![super init]) 71 + if (![self init])
59 return nil; 72 return nil;
60 73
61 self.contents = (id)image; 74 self.contents = (id)image;
@@ -131,17 +144,19 @@ static CGImageRef _markerBlue = nil; @@ -131,17 +144,19 @@ static CGImageRef _markerBlue = nil;
131 - (void) setTextLabel: (NSString*)text 144 - (void) setTextLabel: (NSString*)text
132 { 145 {
133 CGPoint position = CGPointMake([self bounds].size.width / 2 - [text sizeWithFont:[UIFont systemFontOfSize:15]].width / 2, 4); 146 CGPoint position = CGPointMake([self bounds].size.width / 2 - [text sizeWithFont:[UIFont systemFontOfSize:15]].width / 2, 4);
134 - [self setTextLabel:text toPosition:position withFont:[UIFont systemFontOfSize:15] withTextColor:[UIColor blackColor] withBackgroundColor:[UIColor clearColor]]; 147 + [self setTextLabel:text toPosition:position withFont:[UIFont systemFontOfSize:15] withTextColor:[self textForegroundColor] withBackgroundColor:[self textBackgroundColor]];
135 } 148 }
136 149
137 - (void) setTextLabel: (NSString*)text toPosition:(CGPoint)position 150 - (void) setTextLabel: (NSString*)text toPosition:(CGPoint)position
138 { 151 {
139 - [self setTextLabel:text toPosition:position withFont:[UIFont systemFontOfSize:15] withTextColor:[UIColor blackColor] withBackgroundColor:[UIColor clearColor]]; 152 + [self setTextLabel:text toPosition:position withFont:[UIFont systemFontOfSize:15] withTextColor:[self textForegroundColor] withBackgroundColor:[self textBackgroundColor]];
140 } 153 }
141 154
142 - (void) setTextLabel: (NSString*)text withFont:(UIFont*)font withTextColor:(UIColor*)textColor withBackgroundColor:(UIColor*)backgroundColor 155 - (void) setTextLabel: (NSString*)text withFont:(UIFont*)font withTextColor:(UIColor*)textColor withBackgroundColor:(UIColor*)backgroundColor
143 { 156 {
144 CGPoint position = CGPointMake([self bounds].size.width / 2 - [text sizeWithFont:font].width / 2, 4); 157 CGPoint position = CGPointMake([self bounds].size.width / 2 - [text sizeWithFont:font].width / 2, 4);
  158 + [self setTextForegroundColor:textColor];
  159 + [self setTextBackgroundColor:backgroundColor];
145 [self setTextLabel:text toPosition:position withFont:font withTextColor:textColor withBackgroundColor:backgroundColor]; 160 [self setTextLabel:text toPosition:position withFont:font withTextColor:textColor withBackgroundColor:backgroundColor];
146 } 161 }
147 162
@@ -154,6 +169,8 @@ static CGImageRef _markerBlue = nil; @@ -154,6 +169,8 @@ static CGImageRef _markerBlue = nil;
154 textSize.height+4); 169 textSize.height+4);
155 170
156 UILabel *aLabel = [[UILabel alloc] initWithFrame:frame]; 171 UILabel *aLabel = [[UILabel alloc] initWithFrame:frame];
  172 + [self setTextForegroundColor:textColor];
  173 + [self setTextBackgroundColor:backgroundColor];
157 [aLabel setNumberOfLines:0]; 174 [aLabel setNumberOfLines:0];
158 [aLabel setAutoresizingMask:UIViewAutoresizingFlexibleWidth]; 175 [aLabel setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
159 [aLabel setBackgroundColor:backgroundColor]; 176 [aLabel setBackgroundColor:backgroundColor];
@@ -209,8 +226,10 @@ static CGImageRef _markerBlue = nil; @@ -209,8 +226,10 @@ static CGImageRef _markerBlue = nil;
209 226
210 - (void) dealloc 227 - (void) dealloc
211 { 228 {
212 - self.labelView = nil;  
213 - self.data = nil; 229 + self.data = nil;
  230 + self.labelView = nil;
  231 + self.textForegroundColor = nil;
  232 + self.textBackgroundColor = nil;
214 [super dealloc]; 233 [super dealloc];
215 } 234 }
216 235