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

Fix #138

parent 675efab5
#import <React/RCTView.h> #import <React/RCTView.h>
@interface AMapInfoWindow : RCTView @interface AMapCallout : RCTView
@end @end
#import "AMapCallout.h"
@implementation AMapCallout
@end
#import <React/RCTUIManager.h> #import <React/RCTUIManager.h>
#import "AMapInfoWindow.h" #import "AMapCallout.h"
#pragma ide diagnostic ignored "OCUnusedClassInspection" #pragma ide diagnostic ignored "OCUnusedClassInspection"
@interface AMapInfoWindowManager : RCTViewManager @interface AMapCalloutManager : RCTViewManager
@end @end
@implementation AMapInfoWindowManager { @implementation AMapCalloutManager {
} }
RCT_EXPORT_MODULE() RCT_EXPORT_MODULE(AMapInfoWindow)
- (UIView *)view { - (UIView *)view {
return [AMapInfoWindow new]; return [AMapCallout new];
} }
@end @end
#import "AMapInfoWindow.h"
@implementation AMapInfoWindow
@end
#import "AMapView.h" #import "AMapView.h"
#import "AMapInfoWindow.h" #import "AMapCallout.h"
@interface AMapMarker : UIView @interface AMapMarker : UIView
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#import "AMapMarker.h" #import "AMapMarker.h"
#pragma ide diagnostic ignored "OCUnusedMethodInspection" #pragma ide diagnostic ignored "OCUnusedMethodInspection"
#pragma clang diagnostic ignored "-Woverriding-method-mismatch"
@implementation AMapMarker { @implementation AMapMarker {
MAPointAnnotation *_annotation; MAPointAnnotation *_annotation;
...@@ -11,9 +12,10 @@ ...@@ -11,9 +12,10 @@
AMapView *_mapView; AMapView *_mapView;
MAPinAnnotationColor _pinColor; MAPinAnnotationColor _pinColor;
UIImage *_image; UIImage *_image;
BOOL _draggable;
CGPoint _centerOffset; CGPoint _centerOffset;
BOOL _draggable;
BOOL _active; BOOL _active;
BOOL _canShowCallout;
} }
- (instancetype)init { - (instancetype)init {
...@@ -53,7 +55,6 @@ ...@@ -53,7 +55,6 @@
_annotationView.centerOffset = centerOffset; _annotationView.centerOffset = centerOffset;
} }
#pragma clang diagnostic ignored "-Woverriding-method-mismatch"
- (void)setImage:(NSString *)name { - (void)setImage:(NSString *)name {
_image = [UIImage imageNamed:name]; _image = [UIImage imageNamed:name];
if (_image != nil) { if (_image != nil) {
...@@ -83,6 +84,7 @@ ...@@ -83,6 +84,7 @@
} }
- (void)setInfoWindowEnabled:(BOOL)enabled { - (void)setInfoWindowEnabled:(BOOL)enabled {
_canShowCallout = enabled;
_annotationView.canShowCallout = enabled; _annotationView.canShowCallout = enabled;
} }
...@@ -101,6 +103,7 @@ ...@@ -101,6 +103,7 @@
- (MAAnnotationView *)annotationView { - (MAAnnotationView *)annotationView {
if (_annotationView == nil) { if (_annotationView == nil) {
if (_customView) { if (_customView) {
_customView.hidden = NO;
_annotationView = [[MAAnnotationView alloc] initWithAnnotation:_annotation reuseIdentifier:nil]; _annotationView = [[MAAnnotationView alloc] initWithAnnotation:_annotation reuseIdentifier:nil];
_annotationView.bounds = _customView.bounds; _annotationView.bounds = _customView.bounds;
[_annotationView addSubview:_customView]; [_annotationView addSubview:_customView];
...@@ -110,7 +113,7 @@ ...@@ -110,7 +113,7 @@
_annotationView = [[MAPinAnnotationView alloc] initWithAnnotation:_annotation reuseIdentifier:nil]; _annotationView = [[MAPinAnnotationView alloc] initWithAnnotation:_annotation reuseIdentifier:nil];
((MAPinAnnotationView *) _annotationView).pinColor = _pinColor; ((MAPinAnnotationView *) _annotationView).pinColor = _pinColor;
} }
_annotationView.canShowCallout = YES; _annotationView.canShowCallout = _canShowCallout;
_annotationView.draggable = _draggable; _annotationView.draggable = _draggable;
_annotationView.customCalloutView = _calloutView; _annotationView.customCalloutView = _calloutView;
_annotationView.centerOffset = _centerOffset; _annotationView.centerOffset = _centerOffset;
...@@ -123,11 +126,12 @@ ...@@ -123,11 +126,12 @@
} }
- (void)didAddSubview:(UIView *)subview { - (void)didAddSubview:(UIView *)subview {
if ([subview isKindOfClass:[AMapInfoWindow class]]) { if ([subview isKindOfClass:[AMapCallout class]]) {
_calloutView = [[MACustomCalloutView alloc] initWithCustomView:subview]; _calloutView = [[MACustomCalloutView alloc] initWithCustomView:subview];
_annotationView.customCalloutView = _calloutView; _annotationView.customCalloutView = _calloutView;
} else { } else {
_customView = subview; _customView = subview;
_customView.hidden = YES;
} }
} }
......
...@@ -53,7 +53,9 @@ ...@@ -53,7 +53,9 @@
AMapMarker *marker = (AMapMarker *) subview; AMapMarker *marker = (AMapMarker *) subview;
marker.mapView = self; marker.mapView = self;
_markers[[@(marker.annotation.hash) stringValue]] = marker; _markers[[@(marker.annotation.hash) stringValue]] = marker;
dispatch_async(dispatch_get_main_queue(), ^{
[self addAnnotation:marker.annotation]; [self addAnnotation:marker.annotation];
});
} }
if ([subview isKindOfClass:[AMapOverlay class]]) { if ([subview isKindOfClass:[AMapOverlay class]]) {
[self addOverlay:(id <MAOverlay>) subview]; [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