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

新增 iOS Marker#lockToScreen 接口

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