Commit 7590b122 authored by 7c00's avatar 7c00

Fix #138

parent 675efab5
#import <React/RCTView.h>
@interface AMapInfoWindow : RCTView
@interface AMapCallout : RCTView
@end
#import "AMapCallout.h"
@implementation AMapCallout
@end
#import <React/RCTUIManager.h>
#import "AMapInfoWindow.h"
#import "AMapCallout.h"
#pragma ide diagnostic ignored "OCUnusedClassInspection"
@interface AMapInfoWindowManager : RCTViewManager
@interface AMapCalloutManager : RCTViewManager
@end
@implementation AMapInfoWindowManager {
@implementation AMapCalloutManager {
}
RCT_EXPORT_MODULE()
RCT_EXPORT_MODULE(AMapInfoWindow)
- (UIView *)view {
return [AMapInfoWindow new];
return [AMapCallout new];
}
@end
#import "AMapInfoWindow.h"
@implementation AMapInfoWindow
@end
#import "AMapView.h"
#import "AMapInfoWindow.h"
#import "AMapCallout.h"
@interface AMapMarker : UIView
......
......@@ -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 @@
AMapView *_mapView;
MAPinAnnotationColor _pinColor;
UIImage *_image;
BOOL _draggable;
CGPoint _centerOffset;
BOOL _draggable;
BOOL _active;
BOOL _canShowCallout;
}
- (instancetype)init {
......@@ -53,7 +55,6 @@
_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)setInfoWindowEnabled:(BOOL)enabled {
_canShowCallout = enabled;
_annotationView.canShowCallout = enabled;
}
......@@ -101,6 +103,7 @@
- (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 @@
_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 @@
}
- (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;
}
}
......
......@@ -53,7 +53,9 @@
AMapMarker *marker = (AMapMarker *) subview;
marker.mapView = self;
_markers[[@(marker.annotation.hash) stringValue]] = marker;
dispatch_async(dispatch_get_main_queue(), ^{
[self addAnnotation:marker.annotation];
});
}
if ([subview isKindOfClass:[AMapOverlay class]]) {
[self addOverlay:(id <MAOverlay>) subview];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment