diff --git a/Classes/TiGooglemapsViewProxy.m b/Classes/TiGooglemapsViewProxy.m index 530e9fa..a132ece 100644 --- a/Classes/TiGooglemapsViewProxy.m +++ b/Classes/TiGooglemapsViewProxy.m @@ -670,13 +670,28 @@ - (void)animateToLocation:(id)args [[[self mapView] mapView] animateToLocation:CLLocationCoordinate2DMake([TiUtils doubleValue:latitude], [TiUtils doubleValue:longitude])]; } -- (void)animateToZoom:(id)value +- (void)animateToZoom:(NSArray *)value { ENSURE_UI_THREAD(animateToZoom, value); - ENSURE_ARG_COUNT(value, 1); - ENSURE_TYPE([value objectAtIndex:0], NSNumber); - [[[self mapView] mapView] animateToZoom:[TiUtils floatValue:[value objectAtIndex:0]]]; + CGFloat zoomLevel = [TiUtils floatValue:[value objectAtIndex:0]]; + GMSMapView *mapView = [[self mapView] mapView]; + + if (value.count == 2) { + CGPoint point = mapView.center; + CLLocationCoordinate2D location = [mapView.projection coordinateForPoint:point]; + CGFloat duration = [TiUtils floatValue:[value objectAtIndex:1]] / 1000; + + [CATransaction begin]; + [CATransaction setValue:@(duration) forKey:kCATransactionAnimationDuration]; + GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:location.latitude + longitude:location.longitude + zoom:zoomLevel]; + [mapView animateToCameraPosition: camera]; + [CATransaction commit]; + } else { + [mapView animateToZoom:zoomLevel]; + } } - (void)animateToBearing:(id)value diff --git a/README.md b/README.md index 545ae43..7f10396 100644 --- a/README.md +++ b/README.md @@ -233,7 +233,7 @@ mapView.animateToLocation({ ##### Animate to a zoom level: ```js -mapView.animateToZoom(5); +mapView.animateToZoom(5, 2000 /* Optional parameter to specify the duration (in ms) */); ``` ##### Animate to a bearing: diff --git a/manifest b/manifest index ddc34e8..8a60517 100644 --- a/manifest +++ b/manifest @@ -2,7 +2,7 @@ # this is your module manifest and used by Titanium # during compilation, packaging, distribution, etc. # -version: 7.0.1 +version: 7.1.0 apiversion: 2 mac: false architectures: arm64 x86_64