diff --git a/ios/maps/AMapCallout.h b/ios/maps/AMapCallout.h new file mode 100644 index 00000000..05a01325 --- /dev/null +++ b/ios/maps/AMapCallout.h @@ -0,0 +1,4 @@ +#import + +@interface AMapCallout : RCTView +@end diff --git a/ios/maps/AMapCallout.m b/ios/maps/AMapCallout.m new file mode 100644 index 00000000..b4cd0d5a --- /dev/null +++ b/ios/maps/AMapCallout.m @@ -0,0 +1,4 @@ +#import "AMapCallout.h" + +@implementation AMapCallout +@end diff --git a/ios/maps/AMapCalloutManager.m b/ios/maps/AMapCalloutManager.m new file mode 100644 index 00000000..c6aab6a7 --- /dev/null +++ b/ios/maps/AMapCalloutManager.m @@ -0,0 +1,18 @@ +#import +#import "AMapCallout.h" + +#pragma ide diagnostic ignored "OCUnusedClassInspection" + +@interface AMapCalloutManager : RCTViewManager +@end + +@implementation AMapCalloutManager { +} + +RCT_EXPORT_MODULE(AMapInfoWindow) + +- (UIView *)view { + return [AMapCallout new]; +} + +@end diff --git a/ios/maps/AMapInfoWindow.h b/ios/maps/AMapInfoWindow.h deleted file mode 100644 index 8e388746..00000000 --- a/ios/maps/AMapInfoWindow.h +++ /dev/null @@ -1,4 +0,0 @@ -#import - -@interface AMapInfoWindow : RCTView -@end diff --git a/ios/maps/AMapInfoWindow.m b/ios/maps/AMapInfoWindow.m deleted file mode 100644 index 376e2d07..00000000 --- a/ios/maps/AMapInfoWindow.m +++ /dev/null @@ -1,4 +0,0 @@ -#import "AMapInfoWindow.h" - -@implementation AMapInfoWindow -@end diff --git a/ios/maps/AMapInfoWindowManager.m b/ios/maps/AMapInfoWindowManager.m deleted file mode 100644 index 243c2779..00000000 --- a/ios/maps/AMapInfoWindowManager.m +++ /dev/null @@ -1,18 +0,0 @@ -#import -#import "AMapInfoWindow.h" - -#pragma ide diagnostic ignored "OCUnusedClassInspection" - -@interface AMapInfoWindowManager : RCTViewManager -@end - -@implementation AMapInfoWindowManager { -} - -RCT_EXPORT_MODULE() - -- (UIView *)view { - return [AMapInfoWindow new]; -} - -@end diff --git a/ios/maps/AMapMarker.h b/ios/maps/AMapMarker.h index 38f051e3..190db1fb 100644 --- a/ios/maps/AMapMarker.h +++ b/ios/maps/AMapMarker.h @@ -1,5 +1,5 @@ #import "AMapView.h" -#import "AMapInfoWindow.h" +#import "AMapCallout.h" @interface AMapMarker : UIView diff --git a/ios/maps/AMapMarker.m b/ios/maps/AMapMarker.m index ce5d42db..2de7fdbd 100644 --- a/ios/maps/AMapMarker.m +++ b/ios/maps/AMapMarker.m @@ -2,6 +2,7 @@ #import "AMapMarker.h" #pragma ide diagnostic ignored "OCUnusedMethodInspection" +#pragma clang diagnostic ignored "-Woverriding-method-mismatch" @implementation AMapMarker { MAPointAnnotation *_annotation; @@ -11,9 +12,10 @@ @implementation AMapMarker { AMapView *_mapView; MAPinAnnotationColor _pinColor; UIImage *_image; - BOOL _draggable; CGPoint _centerOffset; + BOOL _draggable; BOOL _active; + BOOL _canShowCallout; } - (instancetype)init { @@ -53,7 +55,6 @@ - (void)setCenterOffset:(CGPoint)centerOffset { _annotationView.centerOffset = centerOffset; } -#pragma clang diagnostic ignored "-Woverriding-method-mismatch" - (void)setImage:(NSString *)name { _image = [UIImage imageNamed:name]; if (_image != nil) { @@ -83,6 +84,7 @@ - (void)setClickable:(BOOL)enabled { } - (void)setInfoWindowEnabled:(BOOL)enabled { + _canShowCallout = enabled; _annotationView.canShowCallout = enabled; } @@ -101,6 +103,7 @@ - (void)_handleTap:(UITapGestureRecognizer *)recognizer { - (MAAnnotationView *)annotationView { if (_annotationView == nil) { if (_customView) { + _customView.hidden = NO; _annotationView = [[MAAnnotationView alloc] initWithAnnotation:_annotation reuseIdentifier:nil]; _annotationView.bounds = _customView.bounds; [_annotationView addSubview:_customView]; @@ -110,7 +113,7 @@ - (MAAnnotationView *)annotationView { _annotationView = [[MAPinAnnotationView alloc] initWithAnnotation:_annotation reuseIdentifier:nil]; ((MAPinAnnotationView *) _annotationView).pinColor = _pinColor; } - _annotationView.canShowCallout = YES; + _annotationView.canShowCallout = _canShowCallout; _annotationView.draggable = _draggable; _annotationView.customCalloutView = _calloutView; _annotationView.centerOffset = _centerOffset; @@ -123,11 +126,12 @@ - (MAAnnotationView *)annotationView { } - (void)didAddSubview:(UIView *)subview { - if ([subview isKindOfClass:[AMapInfoWindow class]]) { + if ([subview isKindOfClass:[AMapCallout class]]) { _calloutView = [[MACustomCalloutView alloc] initWithCustomView:subview]; _annotationView.customCalloutView = _calloutView; } else { _customView = subview; + _customView.hidden = YES; } } diff --git a/ios/maps/AMapView.m b/ios/maps/AMapView.m index b1ee0ca6..666b5b25 100644 --- a/ios/maps/AMapView.m +++ b/ios/maps/AMapView.m @@ -53,7 +53,9 @@ - (void)didAddSubview:(UIView *)subview { AMapMarker *marker = (AMapMarker *) subview; marker.mapView = self; _markers[[@(marker.annotation.hash) stringValue]] = marker; - [self addAnnotation:marker.annotation]; + dispatch_async(dispatch_get_main_queue(), ^{ + [self addAnnotation:marker.annotation]; + }); } if ([subview isKindOfClass:[AMapOverlay class]]) { [self addOverlay:(id ) subview];