Commit 8ba0182c authored by 7c00's avatar 7c00

新增 iOS Marker#lockToScreen 接口

相关:#112
parent 7fb5e774
...@@ -12,6 +12,6 @@ ...@@ -12,6 +12,6 @@
- (MAAnnotationView *)annotationView; - (MAAnnotationView *)annotationView;
- (MAPointAnnotation *)annotation; - (MAPointAnnotation *)annotation;
- (void)setMapView:(AMapView *)mapView; - (void)setMapView:(AMapView *)mapView;
- (void)lockToScreen; - (void)lockToScreen:(int)x y:(int)y;
@end @end
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
- (void)setColor:(MAPinAnnotationColor)color { - (void)setColor:(MAPinAnnotationColor)color {
_pinColor = color; _pinColor = color;
((MAPinAnnotationView *)_annotationView).pinColor = color; ((MAPinAnnotationView *) _annotationView).pinColor = color;
} }
- (void)setDraggable:(BOOL)draggable { - (void)setDraggable:(BOOL)draggable {
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(_handleTap:)]]; [UITapGestureRecognizer alloc] initWithTarget:self action:@selector(_handleTap:)]];
} else { } else {
_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 = YES;
_annotationView.draggable = _draggable; _annotationView.draggable = _draggable;
...@@ -131,9 +131,9 @@ ...@@ -131,9 +131,9 @@
} }
} }
- (void)lockToScreen { - (void)lockToScreen:(int)x y:(int)y {
_annotation.lockedToScreen = YES; _annotation.lockedToScreen = YES;
_annotation.lockedScreenPoint = CGPointMake(100, 100); _annotation.lockedScreenPoint = CGPointMake(x, y);
} }
@end @end
#import <React/RCTViewManager.h> #import <React/RCTUIManager.h>
#import "AMapMarker.h" #import "AMapMarker.h"
#pragma ide diagnostic ignored "OCUnusedClassInspection" #pragma ide diagnostic ignored "OCUnusedClassInspection"
...@@ -33,4 +33,11 @@ RCT_EXPORT_VIEW_PROPERTY(onDragStart, RCTBubblingEventBlock) ...@@ -33,4 +33,11 @@ RCT_EXPORT_VIEW_PROPERTY(onDragStart, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onDrag, RCTBubblingEventBlock) RCT_EXPORT_VIEW_PROPERTY(onDrag, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onDragEnd, RCTBubblingEventBlock) RCT_EXPORT_VIEW_PROPERTY(onDragEnd, RCTBubblingEventBlock)
RCT_EXPORT_METHOD(lockToScreen:(nonnull NSNumber *)reactTag x:(int)x y:(int)y) {
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
AMapMarker *marker = (AMapMarker *) viewRegistry[reactTag];
[marker lockToScreen:x y:y];
}];
}
@end @end
...@@ -153,6 +153,10 @@ export default class Marker extends BaseComponent { ...@@ -153,6 +153,10 @@ export default class Marker extends BaseComponent {
this._sendCommand('active') this._sendCommand('active')
} }
lockToScreen(x, y) {
this._sendCommand('lockToScreen', [x, y])
}
componentDidUpdate() { componentDidUpdate() {
if (this._icon && Platform.OS === 'android') { if (this._icon && Platform.OS === 'android') {
setTimeout(() => this._sendCommand('update'), 0) setTimeout(() => this._sendCommand('update'), 0)
......
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