Commit 0021b3fa authored by Qiu Xiang's avatar Qiu Xiang

优化 iOS animated 实现

parent d68065ec
......@@ -175,7 +175,7 @@ class MapView extends Component {
)
break;
case 'ios':
NativeModules.AMapViewManager[command](findNodeHandle(this), params)
NativeModules.AMapViewManager[command](findNodeHandle(this), ...params)
break;
}
}
......
......@@ -16,6 +16,7 @@ export default class AnimatedExample extends Component {
_animatedToZGC() {
this.mapView.animateTo({
tilt: 45,
rotation: 90,
zoomLevel: 18,
coordinate: {
latitude: 39.97837,
......@@ -27,6 +28,7 @@ export default class AnimatedExample extends Component {
_animatedToTAM() {
this.mapView.animateTo({
tilt: 0,
rotation: 0,
zoomLevel: 16,
coordinate: {
latitude: 39.90864,
......
......@@ -48,22 +48,26 @@ RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onLongPress, RCTBubblingEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onLocation, RCTBubblingEventBlock)
RCT_EXPORT_METHOD(animateTo:(nonnull NSNumber *)reactTag data:(NSArray *)data) {
RCT_EXPORT_METHOD(animateTo:(nonnull NSNumber *)reactTag params:(NSDictionary *)params duration:(NSInteger)duration) {
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
AMapView *mapView = (AMapView *) viewRegistry[reactTag];
NSDictionary *params = data[0];
MAMapStatus *mapStatus = mapView.getMapStatus;
if (params[@"zoomLevel"]) {
[mapView setZoomLevel:[params[@"zoomLevel"] floatValue] animated: YES];
mapStatus.zoomLevel = [params[@"zoomLevel"] floatValue];
}
if (params[@"coordinate"]) {
NSDictionary *coordinate = params[@"coordinate"];
[mapView setCenterCoordinate:CLLocationCoordinate2DMake(
mapStatus.centerCoordinate = CLLocationCoordinate2DMake(
[coordinate[@"latitude"] doubleValue],
[coordinate[@"longitude"] doubleValue]) animated:YES];
[coordinate[@"longitude"] doubleValue]);
}
if (params[@"tilt"]) {
[mapView setCameraDegree:[params[@"tilt"] floatValue] animated:YES duration:0.3];
mapStatus.cameraDegree = [params[@"tilt"] floatValue];
}
if (params[@"rotation"]) {
mapStatus.rotationDegree = [params[@"rotation"] floatValue];
}
[mapView setMapStatus:mapStatus animated:YES duration:duration / 1000];
}];
}
......
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