From d0085355a52a4071c94408f9d6d7b407a75ed19e Mon Sep 17 00:00:00 2001 From: lovebing Date: Sun, 14 Jun 2020 00:47:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dios=20marker=20icon=20?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E5=93=8D=E5=BA=94=20click=20=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/RCTBaiduMap/Views/OverlayMarker.m | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/ios/RCTBaiduMap/Views/OverlayMarker.m b/ios/RCTBaiduMap/Views/OverlayMarker.m index 09664267..a011eb20 100644 --- a/ios/RCTBaiduMap/Views/OverlayMarker.m +++ b/ios/RCTBaiduMap/Views/OverlayMarker.m @@ -80,20 +80,21 @@ - (void)updateAnnotation:(BMKPointAnnotationPro *)annotation { } - (void)updateAnnotationView:(BMKPointAnnotationPro *) annotation image:(UIImage *)image { - annotation.annotationView.image = image; _iconImage = image; NSLog(@"annotationView width: %f, height: %f", _icon.size.width, _icon.size.height); if (_icon.size.height > 0 && _icon.size.width > 0) { - annotation.annotationView.image = NULL; - CGRect frame = CGRectMake(-_icon.size.width / 2, -_icon.size.height / 2, _icon.size.width, _icon.size.height); + annotation.annotationView.image = nil; + CGRect frame = CGRectMake(0, 0, _icon.size.width, _icon.size.height); if (_imageView == nil) { _imageView = [[UIImageView alloc] initWithImage:image]; [annotation.annotationView addSubview:_imageView]; } _imageView.frame = frame; + annotation.annotationView.frame = frame; } else { annotation.annotationView.image = image; + annotation.annotationView.frame = CGRectMake(0, 0, CGImageGetWidth(image.CGImage), CGImageGetHeight(image.CGImage)); } annotation.annotationView.pinColor = [self getPinAnnotationColor]; } @@ -119,12 +120,9 @@ - (void)insertReactSubview:(UIView *)subview atIndex:(NSInteger)atIndex { [_annotation updatePaopaoView]; }); } else if([subview isKindOfClass:[OverlayMarkerIcon class]]) { - UIGraphicsBeginImageContextWithOptions(subview.frame.size, YES, [UIScreen mainScreen].scale); - [subview.layer renderInContext:UIGraphicsGetCurrentContext()]; - UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); dispatch_async(dispatch_get_main_queue(), ^{ _annotation.annotationView.image = nil; + _annotation.annotationView.frame = subview.frame; [_annotation.annotationView addSubview:subview]; }); }