Skip to content

Commit 3b965e3

Browse files
author
lempere
committed
Allow set color marker in hex android/ios
1 parent aa477c1 commit 3b965e3

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

src/android/plugin/google/maps/PluginMarker.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,10 @@ protected Bitmap drawLabel(Bitmap image, Bundle labelOptions) {
12041204

12051205
int color = Color.BLACK;
12061206
if (labelOptions.containsKey("color")) {
1207-
color = labelOptions.getInt("color");
1207+
color = labelOptions.getInt("color", -1);
1208+
if(color == -1 && labelOptions.getString("color", "") != "") {
1209+
color = Color.parseColor(labelOptions.getString("color"));
1210+
}
12081211
}
12091212
boolean bold = false;
12101213
if (labelOptions.containsKey("bold")) {

src/ios/GoogleMaps/PluginMarker.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1442,7 +1442,14 @@ - (UIImage *)drawLabel:(UIImage *) image labelOptions:(NSDictionary *)labelOptio
14421442

14431443

14441444
if ([labelOptions objectForKey:@"color"]) {
1445-
textColor = [[labelOptions objectForKey:@"color"] parsePluginColor];
1445+
if ( [[labelOptions objectForKey:@"color"] isKindOfClass:[NSString class]]) {
1446+
NSString* hex = [[labelOptions objectForKey:@"color"] stringByReplacingOccurrencesOfString:@"#" withString:@""];
1447+
unsigned colorInt = 0;
1448+
[[NSScanner scannerWithString:hex] scanHexInt:&colorInt];
1449+
textColor = UIColorFromRGB(colorInt);
1450+
} else {
1451+
textColor = [[labelOptions objectForKey:@"color"] parsePluginColor];
1452+
}
14461453
}
14471454

14481455
// Calculate the size for the title strings

src/ios/GoogleMaps/PluginUtil.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ typedef void (^MYCompletionHandler)(NSError *error);
3030
#define SWITCH(s) for (NSString *__s__ = (s); __s__; __s__ = nil)
3131
#define DEFAULT
3232

33+
#define UIColorFromRGB(rgbValue) [UIColor \
34+
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
35+
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
36+
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
37+
3338
@interface UIView (GoogleMapsPlugin)
3439
- (void)setFrameWithDictionary:(NSDictionary *) params;
3540
- (void)setFrameWithInt:(int)left top:(int)top width:(int)width height:(int)height;

0 commit comments

Comments
 (0)