Skip to content

Commit 7a5fbe4

Browse files
committed
Merge branch 'test'
2 parents d76dc75 + 441ec99 commit 7a5fbe4

3 files changed

Lines changed: 71 additions & 45 deletions

File tree

src/ios/GoogleMaps/GoogleMaps.m

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,9 +507,19 @@ - (void)showDialog:(CDVInvokedUrlCommand *)command {
507507
CGRect pluginRect = self.mapCtrl.view.frame;
508508
pluginRect.origin.x = 0;
509509
pluginRect.origin.y = 0;
510-
int direction = self.mapCtrl.interfaceOrientation;
510+
int direction;
511+
512+
#if !defined(__IPHONE_8_0)
513+
// iOS 7
514+
direction = self.mapCtrl.interfaceOrientation;
515+
#else
516+
// iOS8 or above
517+
direction = [UIDevice currentDevice].orientation;
518+
#endif
519+
520+
511521
if (direction == UIInterfaceOrientationLandscapeLeft ||
512-
direction == UIInterfaceOrientationLandscapeRight) {
522+
direction == UIInterfaceOrientationLandscapeRight) {
513523
pluginRect.size.width = screenSize.size.height;
514524
pluginRect.size.height = screenSize.size.width - footerHeight - footerAdjustment;
515525
} else {

src/ios/GoogleMaps/GoogleMapsViewController.m

Lines changed: 54 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -382,14 +382,16 @@ -(UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker*)marker
382382
isTextMode = false;
383383
NSArray *tmp = [title componentsSeparatedByString:@","];
384384
NSData *decodedData;
385-
#ifdef __IPHONE_7_0
385+
#if !defined(__IPHONE_8_0)
386+
decodedData = [[NSData alloc] initWithBase64Encoding:(NSString *)tmp[1]];
387+
#else
386388
if ([PluginUtil isIOS7_OR_OVER]) {
387-
decodedData = [[NSData alloc] initWithBase64Encoding:(NSString *)tmp[1]];
388-
} else {
389389
decodedData = [NSData dataFromBase64String:tmp[1]];
390+
} else {
391+
#if !defined(__IPHONE_7_0)
392+
decodedData = [[NSData alloc] initWithBase64Encoding:(NSString *)tmp[1]];
393+
#endif
390394
}
391-
#else
392-
decodedData = [NSData dataFromBase64String:tmp[1]];
393395
#endif
394396

395397
base64Image = [[UIImage alloc] initWithData:decodedData];
@@ -410,15 +412,15 @@ -(UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker*)marker
410412
}
411413
}
412414
if (isBold == TRUE && isItalic == TRUE) {
413-
if ([PluginUtil isIOS7_OR_OVER] == true) {
415+
#ifdef __IPHONE_7_0
414416
// ref: http://stackoverflow.com/questions/4713236/how-do-i-set-bold-and-italic-on-uilabel-of-iphone-ipad#21777132
415417
titleFont = [UIFont systemFontOfSize:17.0f];
416418
UIFontDescriptor *fontDescriptor = [titleFont.fontDescriptor
417419
fontDescriptorWithSymbolicTraits:UIFontDescriptorTraitBold | UIFontDescriptorTraitItalic];
418420
titleFont = [UIFont fontWithDescriptor:fontDescriptor size:0];
419-
} else {
421+
#else
420422
titleFont = [UIFont fontWithName:@"Helvetica-BoldOblique" size:17.0];
421-
}
423+
#endif
422424
} else if (isBold == TRUE && isItalic == FALSE) {
423425
titleFont = [UIFont boldSystemFontOfSize:17.0f];
424426
} else if (isBold == TRUE && isItalic == FALSE) {
@@ -428,14 +430,33 @@ -(UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker*)marker
428430
}
429431

430432
// Calculate the size for the title strings
431-
textSize = [title sizeWithFont:titleFont constrainedToSize: CGSizeMake(mapView.frame.size.width - 13, mapView.frame.size.height - 13)];
433+
CGSize tmpSize = CGSizeMake(mapView.frame.size.width - 13, mapView.frame.size.height - 13);
434+
#if !defined(__IPHONE_8_0)
435+
textSize = [title sizeWithFont:titleFont constrainedToSize: tmpSize];
436+
#else
437+
NSDictionary *attr = @{ NSFontAttributeName: titleFont};
438+
textSize = [title boundingRectWithSize:tmpSize
439+
options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingTruncatesLastVisibleLine
440+
attributes:attr
441+
context:nil].size;
442+
#endif
432443
rectSize = CGSizeMake(textSize.width + 10, textSize.height + 22);
433444

434445
// Calculate the size for the snippet strings
435446
if (snippet) {
436447
snippetFont = [UIFont systemFontOfSize:12.0f];
437448
snippet = [snippet stringByReplacingOccurrencesOfString:@"\n" withString:@""];
438-
snippetSize = [snippet sizeWithFont:snippetFont constrainedToSize: CGSizeMake(mapView.frame.size.width - 13, mapView.frame.size.height - 13)];
449+
450+
451+
#if !defined(__IPHONE_8_0)
452+
snippetSize = [snippet sizeWithFont:snippetFont constrainedToSize: tmpSize];
453+
#else
454+
NSDictionary *attr = @{ NSFontAttributeName: snippetFont};
455+
snippetSize = [snippet boundingRectWithSize:tmpSize
456+
options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingTruncatesLastVisibleLine
457+
attributes:attr
458+
context:nil].size;
459+
#endif
439460
rectSize.height += snippetSize.height + 4;
440461
if (rectSize.width < snippetSize.width + leftImg.size.width) {
441462
rectSize.width = snippetSize.width + leftImg.size.width;
@@ -573,7 +594,7 @@ -(UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker*)marker
573594
}
574595

575596
CGRect textRect = CGRectMake(5, 5 , rectSize.width - 10, textSize.height );
576-
if ([PluginUtil isIOS7_OR_OVER] == true) {
597+
#if defined(__IPHONE_7_0)
577598
// iOS7 and above
578599
NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
579600
style.lineBreakMode = NSLineBreakByWordWrapping;
@@ -586,43 +607,41 @@ -(UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker*)marker
586607
};
587608
[title drawInRect:textRect
588609
withAttributes:attributes];
589-
590-
591-
} else {
610+
#else
592611
// iOS6
593612
[titleColor set];
594613
[title drawInRect:textRect
595614
withFont:titleFont
596615
lineBreakMode:NSLineBreakByWordWrapping
597616
alignment:textAlignment];
598-
}
617+
#endif
599618
//CGContextSetRGBStrokeColor(context, 1.0, 0.0, 0.0, 0.5);
600619
//CGContextStrokeRect(context, textRect);
601620
}
602621

603622
//Draw the snippet
604623
if (snippet) {
605624
CGRect textRect = CGRectMake(5, textSize.height + 10 , rectSize.width - 10, snippetSize.height );
606-
if ([PluginUtil isIOS7_OR_OVER] == true) {
607-
// iOS7 and above
608-
NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
609-
style.lineBreakMode = NSLineBreakByWordWrapping;
610-
style.alignment = textAlignment;
611-
612-
NSDictionary *attributes = @{
613-
NSForegroundColorAttributeName : [UIColor grayColor],
614-
NSFontAttributeName : snippetFont,
615-
NSParagraphStyleAttributeName : style
616-
};
617-
[snippet drawInRect:textRect withAttributes:attributes];
618-
} else {
619-
// iOS6
620-
[[UIColor grayColor] set];
621-
[snippet drawInRect:textRect
622-
withFont:snippetFont
623-
lineBreakMode:NSLineBreakByWordWrapping
624-
alignment:textAlignment];
625-
}
625+
#if defined(__IPHONE_7_0)
626+
// iOS7 and above
627+
NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
628+
style.lineBreakMode = NSLineBreakByWordWrapping;
629+
style.alignment = textAlignment;
630+
631+
NSDictionary *attributes = @{
632+
NSForegroundColorAttributeName : [UIColor grayColor],
633+
NSFontAttributeName : snippetFont,
634+
NSParagraphStyleAttributeName : style
635+
};
636+
[snippet drawInRect:textRect withAttributes:attributes];
637+
#else
638+
// iOS6
639+
[[UIColor grayColor] set];
640+
[snippet drawInRect:textRect
641+
withFont:snippetFont
642+
lineBreakMode:NSLineBreakByWordWrapping
643+
alignment:textAlignment];
644+
#endif
626645
}
627646
} else {
628647
//Draw the content image

src/ios/GoogleMaps/Marker.m

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -624,20 +624,17 @@ -(void)setIcon_:(GMSMarker *)marker iconProperty:(NSDictionary *)iconProperty
624624
NSArray *tmp = [iconPath componentsSeparatedByString:@","];
625625

626626
NSData *decodedData;
627-
#ifdef __IPHONE_7_0
627+
#if !defined(__IPHONE_8_0)
628628
if ([PluginUtil isIOS7_OR_OVER]) {
629-
decodedData = [[NSData alloc] initWithBase64Encoding:(NSString *)tmp[1]];
630-
} else {
631629
decodedData = [NSData dataFromBase64String:tmp[1]];
630+
} else {
631+
#if !defined(__IPHONE_7_0)
632+
decodedData = [[NSData alloc] initWithBase64Encoding:(NSString *)tmp[1]];
633+
#endif
632634
}
633635
#else
634636
decodedData = [NSData dataFromBase64String:tmp[1]];
635637
#endif
636-
if ([PluginUtil isIOS7_OR_OVER]) {
637-
decodedData = [[NSData alloc] initWithBase64EncodedString:tmp[1] options:0];
638-
} else {
639-
decodedData = [NSData dataFromBase64String:tmp[1]];
640-
}
641638
image = [[UIImage alloc] initWithData:decodedData];
642639
if (width && height) {
643640
image = [image resize:width height:height];

0 commit comments

Comments
 (0)