Skip to content

Commit

Permalink
Fix #138
Browse files Browse the repository at this point in the history
  • Loading branch information
qiuxiang committed Dec 23, 2017
1 parent 675efab commit 7590b12
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 32 deletions.
4 changes: 4 additions & 0 deletions ios/maps/AMapCallout.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#import <React/RCTView.h>

@interface AMapCallout : RCTView
@end
4 changes: 4 additions & 0 deletions ios/maps/AMapCallout.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#import "AMapCallout.h"

@implementation AMapCallout
@end
18 changes: 18 additions & 0 deletions ios/maps/AMapCalloutManager.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#import <React/RCTUIManager.h>
#import "AMapCallout.h"

#pragma ide diagnostic ignored "OCUnusedClassInspection"

@interface AMapCalloutManager : RCTViewManager
@end

@implementation AMapCalloutManager {
}

RCT_EXPORT_MODULE(AMapInfoWindow)

- (UIView *)view {
return [AMapCallout new];
}

@end
4 changes: 0 additions & 4 deletions ios/maps/AMapInfoWindow.h

This file was deleted.

4 changes: 0 additions & 4 deletions ios/maps/AMapInfoWindow.m

This file was deleted.

18 changes: 0 additions & 18 deletions ios/maps/AMapInfoWindowManager.m

This file was deleted.

2 changes: 1 addition & 1 deletion ios/maps/AMapMarker.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import "AMapView.h"
#import "AMapInfoWindow.h"
#import "AMapCallout.h"

@interface AMapMarker : UIView

Expand Down
12 changes: 8 additions & 4 deletions ios/maps/AMapMarker.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#import "AMapMarker.h"

#pragma ide diagnostic ignored "OCUnusedMethodInspection"
#pragma clang diagnostic ignored "-Woverriding-method-mismatch"

@implementation AMapMarker {
MAPointAnnotation *_annotation;
Expand All @@ -11,9 +12,10 @@ @implementation AMapMarker {
AMapView *_mapView;
MAPinAnnotationColor _pinColor;
UIImage *_image;
BOOL _draggable;
CGPoint _centerOffset;
BOOL _draggable;
BOOL _active;
BOOL _canShowCallout;
}

- (instancetype)init {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -83,6 +84,7 @@ - (void)setClickable:(BOOL)enabled {
}

- (void)setInfoWindowEnabled:(BOOL)enabled {
_canShowCallout = enabled;
_annotationView.canShowCallout = enabled;
}

Expand All @@ -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];
Expand All @@ -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;
Expand All @@ -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;
}
}

Expand Down
4 changes: 3 additions & 1 deletion ios/maps/AMapView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 <MAOverlay>) subview];
Expand Down

0 comments on commit 7590b12

Please sign in to comment.