Commit aeeca19f authored by Qiu Xiang's avatar Qiu Xiang

实现 iOS onStatusChange 事件接口

parent e0ce0319
......@@ -6,5 +6,7 @@
@property(nonatomic, copy) RCTBubblingEventBlock onLocation;
@property(nonatomic, copy) RCTBubblingEventBlock onPress;
@property(nonatomic, copy) RCTBubblingEventBlock onLongPress;
@property(nonatomic, copy) RCTBubblingEventBlock onStatusChange;
@property(nonatomic, copy) RCTBubblingEventBlock onStatusChangeComplete;
@end
\ No newline at end of file
......@@ -48,6 +48,8 @@ RCT_EXPORT_VIEW_PROPERTY(rotation, CGFloat)
RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onLongPress, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onLocation, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onStatusChange, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onStatusChangeComplete, RCTBubblingEventBlock)
RCT_EXPORT_METHOD(animateTo:(nonnull NSNumber *)reactTag params:(NSDictionary *)params duration:(NSInteger)duration) {
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
......@@ -157,4 +159,26 @@ RCT_EXPORT_METHOD(animateTo:(nonnull NSNumber *)reactTag params:(NSDictionary *)
}
}
- (NSDictionary *)buildStatusData:(MAMapStatus *)status {
return @{
@"zoomLevel": @(status.zoomLevel),
@"tilt": @(status.cameraDegree),
@"rotation": @(status.rotationDegree),
@"latitude": @(status.centerCoordinate.latitude),
@"longitude": @(status.centerCoordinate.longitude),
};
}
- (void)mapViewRegionChanged:(AMapView *)mapView {
if (mapView.onStatusChange) {
mapView.onStatusChange([self buildStatusData:mapView.getMapStatus]);
}
}
- (void)mapView:(AMapView *)mapView regionDidChangeAnimated:(BOOL)animated {
if (mapView.onStatusChangeComplete) {
mapView.onStatusChangeComplete([self buildStatusData:mapView.getMapStatus]);
}
}
@end
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